diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 000000000..cdb9db478 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,3 @@ +exclude_paths: + # Github + - .github diff --git a/.config/molecule/config.yml b/.config/molecule/config.yml new file mode 100644 index 000000000..e0665c532 --- /dev/null +++ b/.config/molecule/config.yml @@ -0,0 +1,82 @@ +--- + +driver: + name: docker + +platforms: + - name: debian.stretch + groups: [debian] + image: jrei/systemd-debian:stretch + dockerfile: ../Dockerfile.debian.stretch.j2 + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + tmpfs: + - /tmp + override_command: false + - name: debian.buster + groups: [debian] + image: jrei/systemd-debian:buster + dockerfile: ../Dockerfile.debian.buster.j2 + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + tmpfs: + - /tmp + override_command: false + - name: debian.bullseye + groups: [debian] + image: jrei/systemd-debian:bullseye + dockerfile: ../Dockerfile.debian.bullseye.j2 + privileged: true + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + tmpfs: + - /tmp + override_command: false + +provisioner: + name: ansible + config_options: + defaults: + stdout_callback: yaml + gathering: smart + fact_caching: jsonfile + fact_caching_connection: facts.json + fact_caching_timeout: 3600 + inventory: + host_vars: + debian.stretch: + # Force python version on debian stretch + ansible_python_interpreter: /usr/bin/python3 + +scenario: + create_sequence: + - create + - prepare + cleanup_sequence: + - cleanup + check_sequence: + - cleanup + - destroy + - create + - prepare + - converge + - check + - cleanup + - destroy + converge_sequence: + - create + - prepare + - converge + destroy_sequence: + - cleanup + - destroy + test_sequence: + - cleanup + - destroy + - create + - prepare + - converge + - cleanup + - destroy diff --git a/.env.dist b/.env.dist index 921f6385e..f325388dc 100644 --- a/.env.dist +++ b/.env.dist @@ -1,14 +1,2 @@ -# Ansible -#ANSIBLE_VERSION=edge - -# Verbose -#VERBOSE=2 - -# Cache -#CACHE_DIR=$(HOME)/workspace/manala/ansible/roles/.cache - # Collection #COLLECTION_API_TOKEN= - -# Gitsplit -#export GITSPLIT_GITHUB_API_TOKEN= diff --git a/.github/workflows/collection-release.yaml b/.github/workflows/collection-release.yaml new file mode 100644 index 000000000..4a71bc62a --- /dev/null +++ b/.github/workflows/collection-release.yaml @@ -0,0 +1,77 @@ +--- + +name: Collection Release +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-20.04 + if: "contains(github.event.head_commit.message, 'Release')" + steps: + - name: Notify Slack of starting + uses: act10ns/slack@v1 + with: + status: starting + channel: '#collection_release' + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + - uses: actions/checkout@v2 + + - name: Build Collection + run: make collection.build + + - name: Publish Collection + run: make collection.publish + env: + COLLECTION_API_TOKEN: ${{ secrets.COLLECTION_API_TOKEN }} + + - name: Retrieve version from galaxy.yml + id: get_version + uses: CumulusDS/get-yaml-paths-action@v0.1.0 + with: + file: ./galaxy.yml + version: version + + - name: Get Changelog Entry + id: changelog + uses: mindsers/changelog-reader-action@v2 + with: + path: ./CHANGELOG.md + version: ${{steps.get_version.outputs.version }} + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.changelog.outputs.version }} + release_name: manala-roles ${{ steps.changelog.outputs.version }} + body: ${{ steps.changelog.outputs.changes }} + draft: false + prerelease: false + + - name: Upload Release Asset + id: upload_release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./manala-roles-${{ steps.changelog.outputs.version }}.tar.gz + asset_name: manala-roles-${{ steps.changelog.outputs.version }}.tar.gz + asset_content_type: application/zip + + - name: Notify Slack of action status + uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#collection_release' + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + if: always() diff --git a/.github/workflows/collection-release.yml b/.github/workflows/collection-release.yml deleted file mode 100644 index 115fea409..000000000 --- a/.github/workflows/collection-release.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- - -name: Collection Release -on: - push: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - if: "contains(github.event.head_commit.message, 'Release')" - steps: - - name: Notify Slack of starting - uses: act10ns/slack@v1 - with: - status: starting - channel: '#collection_release' - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - - uses: actions/checkout@v2 - - - name: Prepare Collection - run: make collection.prepare - - - name: Build Collection - run: make collection.build - - - name: Publish Collection - run: make collection.publish - env: - COLLECTION_API_TOKEN: ${{ secrets.COLLECTION_API_TOKEN }} - - - name: Retrieve version from galaxy.yml - id: get_version - uses: CumulusDS/get-yaml-paths-action@v0.1.0 - with: - file: ./galaxy.yml - version: version - - - name: Get Changelog Entry - id: changelog - uses: mindsers/changelog-reader-action@v2 - with: - path: ./CHANGELOG.md - version: ${{steps.get_version.outputs.version }} - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.changelog.outputs.version }} - release_name: manala-roles ${{ steps.changelog.outputs.version }} - body: ${{ steps.changelog.outputs.changes }} - draft: false - prerelease: false - - - name: Upload Release Asset - id: upload_release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./manala-roles-${{ steps.changelog.outputs.version }}.tar.gz - asset_name: manala-roles-${{ steps.changelog.outputs.version }}.tar.gz - asset_content_type: application/zip - - - name: Notify Slack of action status - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#collection_release' - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - if: always() - diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 000000000..d6c3ba3aa --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,17 @@ +name: Lint + +on: + pull_request: + workflow_dispatch: + +jobs: + lint: + name: Lint + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Lint + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: ansible-lint diff --git a/.github/workflows/molecule.accounts.yaml b/.github/workflows/molecule.accounts.yaml new file mode 100644 index 000000000..5c32e3860 --- /dev/null +++ b/.github/workflows/molecule.accounts.yaml @@ -0,0 +1,40 @@ +name: Molecule - Accounts + +on: + pull_request: + paths: + - .github/workflows/molecule.accounts.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/accounts/** + - roles/accounts/** + # Plugins + - plugins/filter/staten.py + - plugins/lookup/accounts_users_authorized_keys.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name accounts \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.alternatives.yaml b/.github/workflows/molecule.alternatives.yaml new file mode 100644 index 000000000..ce9e17e11 --- /dev/null +++ b/.github/workflows/molecule.alternatives.yaml @@ -0,0 +1,39 @@ +name: Molecule - Alternatives + +on: + pull_request: + paths: + - .github/workflows/molecule.alternatives.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/alternatives/** + - roles/alternatives/** + # Plugins + - plugins/filter/staten.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name alternatives \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.ansible.yaml b/.github/workflows/molecule.ansible.yaml new file mode 100644 index 000000000..617d918d5 --- /dev/null +++ b/.github/workflows/molecule.ansible.yaml @@ -0,0 +1,39 @@ +name: Molecule - Ansible + +on: + pull_request: + paths: + - .github/workflows/molecule.ansible.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/ansible/** + - roles/ansible/** + # Plugins + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name ansible \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.ansible_galaxy.yaml b/.github/workflows/molecule.ansible_galaxy.yaml new file mode 100644 index 000000000..472c64296 --- /dev/null +++ b/.github/workflows/molecule.ansible_galaxy.yaml @@ -0,0 +1,39 @@ +name: Molecule - Ansible Galaxy + +on: + pull_request: + paths: + - .github/workflows/molecule.ansible_galaxy.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/ansible_galaxy/** + - roles/ansible_galaxy/** + # Plugins + - plugins/lookup/ansible_galaxy_roles.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name ansible_galaxy \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.apparmor.yaml b/.github/workflows/molecule.apparmor.yaml new file mode 100644 index 000000000..c503d8643 --- /dev/null +++ b/.github/workflows/molecule.apparmor.yaml @@ -0,0 +1,39 @@ +name: Molecule - AppArmor + +on: + pull_request: + paths: + - .github/workflows/molecule.apparmor.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/apparmor/** + - roles/apparmor/** + # Plugins + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name apparmor \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.apt.yaml b/.github/workflows/molecule.apt.yaml new file mode 100644 index 000000000..b42f46820 --- /dev/null +++ b/.github/workflows/molecule.apt.yaml @@ -0,0 +1,45 @@ +name: Molecule - Apt + +on: + pull_request: + paths: + - .github/workflows/molecule.apt.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/apt/** + - roles/apt/** + # Plugins + - plugins/filter/apt_architecture.py + - plugins/lookup/apt_holds.py + - plugins/lookup/apt_keys.py + - plugins/lookup/apt_packages.py + - plugins/lookup/apt_preferences.py + - plugins/lookup/apt_repositories.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name apt \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.aptly.yaml b/.github/workflows/molecule.aptly.yaml new file mode 100644 index 000000000..a446e2baf --- /dev/null +++ b/.github/workflows/molecule.aptly.yaml @@ -0,0 +1,40 @@ +name: Molecule - Aptly + +on: + pull_request: + paths: + - .github/workflows/molecule.aptly.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/aptly/** + - roles/aptly/** + # Plugins + - plugins/filter/json.py + - plugins/filter/staten.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name aptly \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.backup_manager.yaml b/.github/workflows/molecule.backup_manager.yaml new file mode 100644 index 000000000..ea72fe9d7 --- /dev/null +++ b/.github/workflows/molecule.backup_manager.yaml @@ -0,0 +1,40 @@ +name: Molecule - Backup Manager + +on: + pull_request: + paths: + - .github/workflows/molecule.backup_manager.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/backup_manager/** + - roles/backup_manager/** + # Plugins + - plugins/filter/backup_manager_config.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name backup_manager \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.bind.yaml b/.github/workflows/molecule.bind.yaml new file mode 100644 index 000000000..58f0a066e --- /dev/null +++ b/.github/workflows/molecule.bind.yaml @@ -0,0 +1,39 @@ +name: Molecule - Bind + +on: + pull_request: + paths: + - .github/workflows/molecule.bind.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/bind/** + - roles/bind/** + # Plugins + - plugins/filter/bind_zone.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name bind \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.cloud_init.yaml b/.github/workflows/molecule.cloud_init.yaml new file mode 100644 index 000000000..a721850fe --- /dev/null +++ b/.github/workflows/molecule.cloud_init.yaml @@ -0,0 +1,39 @@ +name: Molecule - Clound Init + +on: + pull_request: + paths: + - .github/workflows/molecule.cloud_init.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/cloud_init/** + - roles/cloud_init/** + # Plugins + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name cloud_init \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.composer.yaml b/.github/workflows/molecule.composer.yaml new file mode 100644 index 000000000..a1fc7f19f --- /dev/null +++ b/.github/workflows/molecule.composer.yaml @@ -0,0 +1,39 @@ +name: Molecule - Composer + +on: + pull_request: + paths: + - .github/workflows/molecule.composer.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/composer/** + - roles/composer/** + # Plugins + - plugins/filter/json.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name composer \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.cron.yaml b/.github/workflows/molecule.cron.yaml new file mode 100644 index 000000000..250680433 --- /dev/null +++ b/.github/workflows/molecule.cron.yaml @@ -0,0 +1,40 @@ +name: Molecule - Cron + +on: + pull_request: + paths: + - .github/workflows/molecule.cron.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/cron/** + - roles/cron/** + # Plugins + - plugins/filter/environment.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name cron \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.deploy.yaml b/.github/workflows/molecule.deploy.yaml new file mode 100644 index 000000000..b043b389f --- /dev/null +++ b/.github/workflows/molecule.deploy.yaml @@ -0,0 +1,41 @@ +name: Molecule - Deploy + +on: + pull_request: + paths: + - .github/workflows/molecule.deploy.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/deploy/** + - roles/deploy/** + # Plugins + - plugins/callback/deploy_log.py + - plugins/lookup/deploy_tasks.py + - plugins/lookup/deploy_writable_dirs.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name deploy \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.dhcp.yaml b/.github/workflows/molecule.dhcp.yaml new file mode 100644 index 000000000..4fe1c8e49 --- /dev/null +++ b/.github/workflows/molecule.dhcp.yaml @@ -0,0 +1,37 @@ +name: Molecule - Dhcp + +on: + pull_request: + paths: + - .github/workflows/molecule.dhcp.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/dhcp/** + - roles/dhcp/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name dhcp \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.dnsmasq.yaml b/.github/workflows/molecule.dnsmasq.yaml new file mode 100644 index 000000000..53e653092 --- /dev/null +++ b/.github/workflows/molecule.dnsmasq.yaml @@ -0,0 +1,39 @@ +name: Molecule - Dnsmasq + +on: + pull_request: + paths: + - .github/workflows/molecule.dnsmasq.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/dnsmasq/** + - roles/dnsmasq/** + # Plugins + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name dnsmasq \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.docker.yaml b/.github/workflows/molecule.docker.yaml new file mode 100644 index 000000000..28aef77c2 --- /dev/null +++ b/.github/workflows/molecule.docker.yaml @@ -0,0 +1,41 @@ +name: Molecule - Docker + +on: + pull_request: + paths: + - .github/workflows/molecule.docker.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/docker/** + - roles/docker/** + # Plugins + - plugins/filter/json.py + - plugins/filter/staten.py + - plugins/lookup/docker_applications.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name docker \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.elasticsearch.yaml b/.github/workflows/molecule.elasticsearch.yaml new file mode 100644 index 000000000..26f424f06 --- /dev/null +++ b/.github/workflows/molecule.elasticsearch.yaml @@ -0,0 +1,47 @@ +name: Molecule - Elasticsearch + +on: + pull_request: + paths: + - .github/workflows/molecule.elasticsearch.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/elasticsearch.*/** + - roles/elasticsearch/** + # Plugins + - plugins/filter/environment.py + - plugins/filter/yaml.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + strategy: + matrix: + version: + - 2 + - 5 + - 6 + - 7 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name elasticsearch.${{ matrix.version }} \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.environment.yaml b/.github/workflows/molecule.environment.yaml new file mode 100644 index 000000000..78ecc6bd3 --- /dev/null +++ b/.github/workflows/molecule.environment.yaml @@ -0,0 +1,39 @@ +name: Molecule - Environment + +on: + pull_request: + paths: + - .github/workflows/molecule.environment.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/environment/** + - roles/environment/** + # Plugins + - plugins/lookup/environment_files.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name environment \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.fail2ban.yaml b/.github/workflows/molecule.fail2ban.yaml new file mode 100644 index 000000000..8289ee8bc --- /dev/null +++ b/.github/workflows/molecule.fail2ban.yaml @@ -0,0 +1,37 @@ +name: Molecule - Fail2ban + +on: + pull_request: + paths: + - .github/workflows/molecule.fail2ban.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/fail2ban/** + - roles/fail2ban/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name fail2ban \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.files.yaml b/.github/workflows/molecule.files.yaml new file mode 100644 index 000000000..a99564a9d --- /dev/null +++ b/.github/workflows/molecule.files.yaml @@ -0,0 +1,41 @@ +name: Molecule - Files + +on: + pull_request: + paths: + - .github/workflows/molecule.files.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/files/** + - roles/files/** + # Plugins + - plugins/action/files_attributes.py + - plugins/lookup/files_attributes.py + - plugins/modules/files_attributes.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name files \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.git.yaml b/.github/workflows/molecule.git.yaml new file mode 100644 index 000000000..2f1937d62 --- /dev/null +++ b/.github/workflows/molecule.git.yaml @@ -0,0 +1,39 @@ +name: Molecule - Git + +on: + pull_request: + paths: + - .github/workflows/molecule.git.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/git/** + - roles/git/** + # Plugins + - plugins/filter/git_config.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name git \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.gitlab.yaml b/.github/workflows/molecule.gitlab.yaml new file mode 100644 index 000000000..4174ee010 --- /dev/null +++ b/.github/workflows/molecule.gitlab.yaml @@ -0,0 +1,39 @@ +name: Molecule - Gitlab + +on: + pull_request: + paths: + - .github/workflows/molecule.gitlab.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/gitlab/** + - roles/gitlab/** + # Plugins + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name gitlab \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.glusterfs.yaml b/.github/workflows/molecule.glusterfs.yaml new file mode 100644 index 000000000..3a8adcbf5 --- /dev/null +++ b/.github/workflows/molecule.glusterfs.yaml @@ -0,0 +1,43 @@ +name: Molecule - Glusterfs + +on: + pull_request: + paths: + - .github/workflows/molecule.glusterfs.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/glusterfs.*/** + - roles/glusterfs/** + # Plugins + - plugins/filter/staten.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + strategy: + matrix: + version: + - 6.1 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name glusterfs.${{ matrix.version }} \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.gomplate.yaml b/.github/workflows/molecule.gomplate.yaml new file mode 100644 index 000000000..186c41f8a --- /dev/null +++ b/.github/workflows/molecule.gomplate.yaml @@ -0,0 +1,39 @@ +name: Molecule - Gomplate + +on: + pull_request: + paths: + - .github/workflows/molecule.gomplate.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/gomplate/** + - roles/gomplate/** + # Plugins + - plugins/filter/gomplate_architecture.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name gomplate \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.grafana.yaml b/.github/workflows/molecule.grafana.yaml new file mode 100644 index 000000000..13e52b392 --- /dev/null +++ b/.github/workflows/molecule.grafana.yaml @@ -0,0 +1,37 @@ +name: Molecule - Grafana + +on: + pull_request: + paths: + - .github/workflows/molecule.grafana.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/grafana/** + - roles/grafana/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name grafana \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.haproxy.yaml b/.github/workflows/molecule.haproxy.yaml new file mode 100644 index 000000000..37650ad76 --- /dev/null +++ b/.github/workflows/molecule.haproxy.yaml @@ -0,0 +1,40 @@ +name: Molecule - Haproxy + +on: + pull_request: + paths: + - .github/workflows/molecule.haproxy.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/haproxy/** + - roles/haproxy/** + # Plugins + - plugins/filter/environment.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name haproxy \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.influxdb.yaml b/.github/workflows/molecule.influxdb.yaml new file mode 100644 index 000000000..357b67246 --- /dev/null +++ b/.github/workflows/molecule.influxdb.yaml @@ -0,0 +1,39 @@ +name: Molecule - InfluxDB + +on: + pull_request: + paths: + - .github/workflows/molecule.influxdb.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/influxdb/** + - roles/influxdb/** + # Plugins + - plugins/filter/toml.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name influxdb \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.java.yaml b/.github/workflows/molecule.java.yaml new file mode 100644 index 000000000..d24914669 --- /dev/null +++ b/.github/workflows/molecule.java.yaml @@ -0,0 +1,37 @@ +name: Molecule - Java + +on: + pull_request: + paths: + - .github/workflows/molecule.java.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/java/** + - roles/java/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name java \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.keepalived.yaml b/.github/workflows/molecule.keepalived.yaml new file mode 100644 index 000000000..ea7560808 --- /dev/null +++ b/.github/workflows/molecule.keepalived.yaml @@ -0,0 +1,39 @@ +name: Molecule - Keepalived + +on: + pull_request: + paths: + - .github/workflows/molecule.keepalived.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/keepalived/** + - roles/keepalived/** + # Plugins + - plugins/filter/environment.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name keepalived \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.kernel.yaml b/.github/workflows/molecule.kernel.yaml new file mode 100644 index 000000000..9dd17f1ca --- /dev/null +++ b/.github/workflows/molecule.kernel.yaml @@ -0,0 +1,37 @@ +name: Molecule - Kernel + +on: + pull_request: + paths: + - .github/workflows/molecule.kernel.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/kernel/** + - roles/kernel/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name kernel \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.locales.yaml b/.github/workflows/molecule.locales.yaml new file mode 100644 index 000000000..01af72c5d --- /dev/null +++ b/.github/workflows/molecule.locales.yaml @@ -0,0 +1,39 @@ +name: Molecule - Locales + +on: + pull_request: + paths: + - .github/workflows/molecule.locales.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/locales/** + - roles/locales/** + # Plugins + - plugins/lookup/locales_code.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name locales \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.logrotate.yaml b/.github/workflows/molecule.logrotate.yaml new file mode 100644 index 000000000..6c099086f --- /dev/null +++ b/.github/workflows/molecule.logrotate.yaml @@ -0,0 +1,40 @@ +name: Molecule - Logrotate + +on: + pull_request: + paths: + - .github/workflows/molecule.logrotate.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/logrotate/** + - roles/logrotate/** + # Plugins + - plugins/filter/logrotate_config.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name logrotate \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.make.yaml b/.github/workflows/molecule.make.yaml new file mode 100644 index 000000000..27df11e92 --- /dev/null +++ b/.github/workflows/molecule.make.yaml @@ -0,0 +1,37 @@ +name: Molecule - Make + +on: + pull_request: + paths: + - .github/workflows/molecule.make.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/make/** + - roles/make/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name make \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.maxscale.yaml b/.github/workflows/molecule.maxscale.yaml new file mode 100644 index 000000000..e2622a8ce --- /dev/null +++ b/.github/workflows/molecule.maxscale.yaml @@ -0,0 +1,47 @@ +name: Molecule - MaxScale + +on: + pull_request: + paths: + - .github/workflows/molecule.maxscale.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/maxscale.*/** + - roles/maxscale/** + # Plugins + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + strategy: + matrix: + version: + - 2.2 + - 2.3 + - 2.4 + - 2.5 + - 6.1 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name maxscale.${{ matrix.version }} \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.mongodb.yaml b/.github/workflows/molecule.mongodb.yaml new file mode 100644 index 000000000..c98b1681b --- /dev/null +++ b/.github/workflows/molecule.mongodb.yaml @@ -0,0 +1,45 @@ +name: Molecule - MongoDB + +on: + pull_request: + paths: + - .github/workflows/molecule.mongodb.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/mongodb.*/** + - roles/mongodb/** + # Plugins + - plugins/filter/staten.py + - plugins/filter/yaml.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + strategy: + matrix: + version: + - 3.6 + - 4.4 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name mongodb.${{ matrix.version }} \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.motd.yaml b/.github/workflows/molecule.motd.yaml new file mode 100644 index 000000000..0988b7907 --- /dev/null +++ b/.github/workflows/molecule.motd.yaml @@ -0,0 +1,39 @@ +name: Molecule - Motd + +on: + pull_request: + paths: + - .github/workflows/molecule.motd.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/motd/** + - roles/motd/** + # Plugins + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name motd \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.mount.yaml b/.github/workflows/molecule.mount.yaml new file mode 100644 index 000000000..7c0467762 --- /dev/null +++ b/.github/workflows/molecule.mount.yaml @@ -0,0 +1,39 @@ +name: Molecule - Mount + +on: + pull_request: + paths: + - .github/workflows/molecule.mount.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/mount/** + - roles/mount/** + # Plugins + - plugins/filter/staten.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name mount \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.mysql.yaml b/.github/workflows/molecule.mysql.yaml index a17e56ffa..395273438 100644 --- a/.github/workflows/molecule.mysql.yaml +++ b/.github/workflows/molecule.mysql.yaml @@ -1,9 +1,56 @@ name: Molecule - MySQL on: + pull_request: + paths: + - .github/workflows/molecule.mysql.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/mysql.*/** + - roles/mysql/** + # Plugins + - plugins/filter/mysql_config.py + - plugins/filter/staten.py + - plugins/lookup/templates_exclusive.py workflow_dispatch: inputs: debug: - description: Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate) + description: Run with tmate debugging required: false default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + strategy: + matrix: + version: + - 5.6 + - 5.7 + - "8.0" + - galera.3.mysql_wsrep.5.6 + - mariadb.10.3 + - mariadb.10.4 + - mariadb.10.5 + - mariadb.10.6 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Disable apparmor for mysql + run: | + sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ + sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name mysql.${{ matrix.version }} \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.network.yaml b/.github/workflows/molecule.network.yaml new file mode 100644 index 000000000..8ab2d0312 --- /dev/null +++ b/.github/workflows/molecule.network.yaml @@ -0,0 +1,39 @@ +name: Molecule - Network + +on: + pull_request: + paths: + - .github/workflows/molecule.network.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/network/** + - roles/network/** + # Plugins + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name network \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.nginx.yaml b/.github/workflows/molecule.nginx.yaml new file mode 100644 index 000000000..79fc33344 --- /dev/null +++ b/.github/workflows/molecule.nginx.yaml @@ -0,0 +1,40 @@ +name: Molecule - Nginx + +on: + pull_request: + paths: + - .github/workflows/molecule.nginx.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/nginx/** + - roles/nginx/** + # Plugins + - plugins/filter/nginx_config.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name nginx \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.ngrok.yaml b/.github/workflows/molecule.ngrok.yaml new file mode 100644 index 000000000..8e6b700f5 --- /dev/null +++ b/.github/workflows/molecule.ngrok.yaml @@ -0,0 +1,41 @@ +name: Molecule - Ngrok + +on: + pull_request: + paths: + - .github/workflows/molecule.ngrok.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/ngrok/** + - roles/ngrok/** + # Plugins + - plugins/filter/ngrok_architecture.py + - plugins/filter/yaml.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name ngrok \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.nodejs.yaml b/.github/workflows/molecule.nodejs.yaml new file mode 100644 index 000000000..54061950a --- /dev/null +++ b/.github/workflows/molecule.nodejs.yaml @@ -0,0 +1,49 @@ +name: Molecule - NodeJS + +on: + pull_request: + paths: + - .github/workflows/molecule.nodejs.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/nodejs.*/** + - roles/nodejs/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + strategy: + matrix: + version: + - 4 + - 6 + - 7 + - 8 + - 9 + - 10 + - 12 + - 14 + - 16 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name nodejs.${{ matrix.version }} \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.npm.yaml b/.github/workflows/molecule.npm.yaml new file mode 100644 index 000000000..1af24cdde --- /dev/null +++ b/.github/workflows/molecule.npm.yaml @@ -0,0 +1,37 @@ +name: Molecule - Npm + +on: + pull_request: + paths: + - .github/workflows/molecule.npm.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/npm/** + - roles/npm/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name npm \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.ntp.yaml b/.github/workflows/molecule.ntp.yaml new file mode 100644 index 000000000..084117d61 --- /dev/null +++ b/.github/workflows/molecule.ntp.yaml @@ -0,0 +1,37 @@ +name: Molecule - Ntp + +on: + pull_request: + paths: + - .github/workflows/molecule.ntp.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/ntp/** + - roles/ntp/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name ntp \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.ohmyzsh.yaml b/.github/workflows/molecule.ohmyzsh.yaml new file mode 100644 index 000000000..f7c7d0034 --- /dev/null +++ b/.github/workflows/molecule.ohmyzsh.yaml @@ -0,0 +1,41 @@ +name: Molecule - Oh My Zsh + +on: + pull_request: + paths: + - .github/workflows/molecule.ohmyzsh.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/ohmyzsh/** + - roles/ohmyzsh/** + # Plugins + - plugins/filter/staten.py + - plugins/filter/zsh_config.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name ohmyzsh \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.pam_ssh_agent_auth.yaml b/.github/workflows/molecule.pam_ssh_agent_auth.yaml new file mode 100644 index 000000000..8de80e386 --- /dev/null +++ b/.github/workflows/molecule.pam_ssh_agent_auth.yaml @@ -0,0 +1,37 @@ +name: Molecule - Pam ssh agent auth + +on: + pull_request: + paths: + - .github/workflows/molecule.pam_ssh_agent_auth.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/pam_ssh_agent_auth/** + - roles/pam_ssh_agent_auth/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name pam_ssh_agent_auth \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.php.yaml b/.github/workflows/molecule.php.yaml new file mode 100644 index 000000000..663688516 --- /dev/null +++ b/.github/workflows/molecule.php.yaml @@ -0,0 +1,58 @@ +name: Molecule - Php + +on: + pull_request: + paths: + - .github/workflows/molecule.php.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/php.*/** + - roles/php/** + # Plugins + - plugins/filter/php_blackfire_config.py + - plugins/filter/php_config.py + - plugins/filter/php_fpm_pools.py + - plugins/lookup/php_applications.py + - plugins/lookup/php_extensions.py + - plugins/lookup/php_packages_exclusive.py + - plugins/lookup/php_packages.py + - plugins/lookup/php_sapis.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + strategy: + matrix: + version: + - 5.6 + - "7.0" + - 7.1 + - 7.2 + - 7.3 + - 7.4 + - "8.0" + - 8.1 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name php.${{ matrix.version }} \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.postgresql.yaml b/.github/workflows/molecule.postgresql.yaml new file mode 100644 index 000000000..fc71f7de8 --- /dev/null +++ b/.github/workflows/molecule.postgresql.yaml @@ -0,0 +1,41 @@ +name: Molecule - PostgreSQL + +on: + pull_request: + paths: + - .github/workflows/molecule.postgresql.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/postgresql.*/** + - roles/postgresql/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + strategy: + matrix: + version: + - 9.4 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name postgresql.${{ matrix.version }} \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.proftpd.yaml b/.github/workflows/molecule.proftpd.yaml new file mode 100644 index 000000000..7082961a0 --- /dev/null +++ b/.github/workflows/molecule.proftpd.yaml @@ -0,0 +1,40 @@ +name: Molecule - Proftpd + +on: + pull_request: + paths: + - .github/workflows/molecule.proftpd.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/proftpd/** + - roles/proftpd/** + # Plugins + - plugins/filter/proftpd_config.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name proftpd \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.redis.yaml b/.github/workflows/molecule.redis.yaml new file mode 100644 index 000000000..5ebca70da --- /dev/null +++ b/.github/workflows/molecule.redis.yaml @@ -0,0 +1,45 @@ +name: Molecule - Redis + +on: + pull_request: + paths: + - .github/workflows/molecule.redis.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/redis.*/** + - roles/redis/** + # Plugins + - plugins/filter/redis_config.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + strategy: + matrix: + version: + - 3.2 + - "5.0" + - "6.0" + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name redis.${{ matrix.version }} \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.rsyslog.yaml b/.github/workflows/molecule.rsyslog.yaml new file mode 100644 index 000000000..bcfd30577 --- /dev/null +++ b/.github/workflows/molecule.rsyslog.yaml @@ -0,0 +1,40 @@ +name: Molecule - Rsyslog + +on: + pull_request: + paths: + - .github/workflows/molecule.rsyslog.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/rsyslog/** + - roles/rsyslog/** + # Plugins + - plugins/filter/rsyslog_config.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name rsyslog \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.sensu_go.yaml b/.github/workflows/molecule.sensu_go.yaml new file mode 100644 index 000000000..99c8858e5 --- /dev/null +++ b/.github/workflows/molecule.sensu_go.yaml @@ -0,0 +1,37 @@ +name: Molecule - Sensu Go + +on: + pull_request: + paths: + - .github/workflows/molecule.sensu_go.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/sensu_go/** + - roles/sensu_go/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name sensu_go \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.shorewall.yaml b/.github/workflows/molecule.shorewall.yaml new file mode 100644 index 000000000..7ed1ba0aa --- /dev/null +++ b/.github/workflows/molecule.shorewall.yaml @@ -0,0 +1,39 @@ +name: Molecule - Shorewall + +on: + pull_request: + paths: + - .github/workflows/molecule.shorewall.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/shorewall/** + - roles/shorewall/** + # Plugins + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name shorewall \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.sqlite.yaml b/.github/workflows/molecule.sqlite.yaml new file mode 100644 index 000000000..6c2f925db --- /dev/null +++ b/.github/workflows/molecule.sqlite.yaml @@ -0,0 +1,37 @@ +name: Molecule - Sqlite + +on: + pull_request: + paths: + - .github/workflows/molecule.sqlite.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/sqlite/** + - roles/sqlite/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name sqlite \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.ssh.yaml b/.github/workflows/molecule.ssh.yaml new file mode 100644 index 000000000..ecff8155f --- /dev/null +++ b/.github/workflows/molecule.ssh.yaml @@ -0,0 +1,40 @@ +name: Molecule - Ssh + +on: + pull_request: + paths: + - .github/workflows/molecule.ssh.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/ssh/** + - roles/ssh/** + # Plugins + - plugins/filter/ssh_config.py + - plugins/lookup/ssh_known_hosts.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name ssh \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.sudo.yaml b/.github/workflows/molecule.sudo.yaml new file mode 100644 index 000000000..bdc5d2806 --- /dev/null +++ b/.github/workflows/molecule.sudo.yaml @@ -0,0 +1,39 @@ +name: Molecule - Sudo + +on: + pull_request: + paths: + - .github/workflows/molecule.sudo.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/sudo/** + - roles/sudo/** + # Plugins + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name sudo \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.supervisor.yaml b/.github/workflows/molecule.supervisor.yaml new file mode 100644 index 000000000..3a2374f1a --- /dev/null +++ b/.github/workflows/molecule.supervisor.yaml @@ -0,0 +1,40 @@ +name: Molecule - Supervisor + +on: + pull_request: + paths: + - .github/workflows/molecule.supervisor.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/supervisor/** + - roles/supervisor/** + # Plugins + - plugins/filter/supervisor_config.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name supervisor \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.symfony_cli.yaml b/.github/workflows/molecule.symfony_cli.yaml new file mode 100644 index 000000000..defb02728 --- /dev/null +++ b/.github/workflows/molecule.symfony_cli.yaml @@ -0,0 +1,39 @@ +name: Molecule - Symfony cli + +on: + pull_request: + paths: + - .github/workflows/molecule.symfony_cli.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/symfony_cli/** + - roles/symfony_cli/** + # Plugins + - plugins/filter/symfony_cli_architecture.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name symfony_cli \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.systemd.yaml b/.github/workflows/molecule.systemd.yaml new file mode 100644 index 000000000..48987ab4c --- /dev/null +++ b/.github/workflows/molecule.systemd.yaml @@ -0,0 +1,40 @@ +name: Molecule - Systemd + +on: + pull_request: + paths: + - .github/workflows/molecule.systemd.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/systemd/** + - roles/systemd/** + # Plugins + - plugins/filter/staten.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name systemd \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.telegraf.yaml b/.github/workflows/molecule.telegraf.yaml new file mode 100644 index 000000000..874517a36 --- /dev/null +++ b/.github/workflows/molecule.telegraf.yaml @@ -0,0 +1,40 @@ +name: Molecule - Telegraf + +on: + pull_request: + paths: + - .github/workflows/molecule.telegraf.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/telegraf/** + - roles/telegraf/** + # Plugins + - plugins/filter/toml.py + - plugins/lookup/templates_exclusive.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name telegraf \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.timezone.yaml b/.github/workflows/molecule.timezone.yaml new file mode 100644 index 000000000..3172a5309 --- /dev/null +++ b/.github/workflows/molecule.timezone.yaml @@ -0,0 +1,37 @@ +name: Molecule - Timezone + +on: + pull_request: + paths: + - .github/workflows/molecule.timezone.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/timezone/** + - roles/timezone/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name timezone \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.vault_cli.yaml b/.github/workflows/molecule.vault_cli.yaml new file mode 100644 index 000000000..924414d4a --- /dev/null +++ b/.github/workflows/molecule.vault_cli.yaml @@ -0,0 +1,39 @@ +name: Molecule - Vault cli + +on: + pull_request: + paths: + - .github/workflows/molecule.vault_cli.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/vault_cli/** + - roles/vault_cli/** + # Plugins + - plugins/filter/vault_cli_architecture.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name vault_cli \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.vim.yaml b/.github/workflows/molecule.vim.yaml new file mode 100644 index 000000000..a3ed830fa --- /dev/null +++ b/.github/workflows/molecule.vim.yaml @@ -0,0 +1,39 @@ +name: Molecule - Vim + +on: + pull_request: + paths: + - .github/workflows/molecule.vim.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/vim/** + - roles/vim/** + # Plugins + - plugins/filter/vim_config.py + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name vim \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.yarn.yaml b/.github/workflows/molecule.yarn.yaml new file mode 100644 index 000000000..a97d1ec64 --- /dev/null +++ b/.github/workflows/molecule.yarn.yaml @@ -0,0 +1,37 @@ +name: Molecule - Yarn + +on: + pull_request: + paths: + - .github/workflows/molecule.yarn.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/yarn/** + - roles/yarn/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name yarn \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/molecule.zsh.yaml b/.github/workflows/molecule.zsh.yaml new file mode 100644 index 000000000..fe42ff65c --- /dev/null +++ b/.github/workflows/molecule.zsh.yaml @@ -0,0 +1,37 @@ +name: Molecule - Zsh + +on: + pull_request: + paths: + - .github/workflows/molecule.zsh.yml + - .config/molecule/config.yml + - molecule/Dockerfile.* + - molecule/zsh/** + - roles/zsh/** + workflow_dispatch: + inputs: + debug: + description: Run with tmate debugging + required: false + default: false + +jobs: + molecule: + name: Molecule + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Molecule + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && molecule converge --scenario-name zsh \ + " + - name: Debug + uses: mxschmitt/action-tmate@v3 + if: github.event.inputs.debug && always() diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 000000000..33f2e2549 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,51 @@ +name: Test + +on: + pull_request: + workflow_dispatch: + +jobs: + test: + name: Test + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ansible_collections/manala/roles + - name: Sanity + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && ansible-test sanity --python 3.8 --requirements --verbose --color \ + " + - name: Units + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && ansible-test units --python 3.8 --requirements --coverage --verbose --color \ + " + - name: Integration + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && ansible-test integration --python 3.8 --requirements --coverage --verbose --color \ + " + - name: Coverage + uses: docker://quay.io/ansible/toolset:3.5.0 + with: + args: | + sh -c " \ + cd ansible_collections/manala/roles \ + && ansible-test coverage xml --python 3.8 --requirements --group-by command --group-by version --verbose --color \ + " + - name: Codecov + uses: codecov/codecov-action@v1 + with: + fail_ci_if_error: false diff --git a/.gitignore b/.gitignore index 7ed6f6c33..ef4df1364 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,2 @@ -/.gitsplit/ -/.cache/ .env -manala-roles-*.tar.gz -/collection/ +manala-roles-* diff --git a/.gitsplit.yml b/.gitsplit.yml deleted file mode 100644 index e8bb307df..000000000 --- a/.gitsplit.yml +++ /dev/null @@ -1,177 +0,0 @@ -# Used to speed up the split over time by reusing git's objects -cache_url: "./.gitsplit" - -# List of splits. -splits: - - prefix: roles/accounts - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-accounts.git - - prefix: roles/alternatives - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-alternatives.git - - prefix: roles/ansible - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-ansible.git - - prefix: roles/ansible_galaxy - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-ansible_galaxy.git - - prefix: roles/apparmor - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-apparmor.git - - prefix: roles/apt - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-apt.git - - prefix: roles/aptly - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-aptly.git - - prefix: roles/backup_manager - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-backup_manager.git - - prefix: roles/beanstalkd - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-beanstalkd.git - - prefix: roles/bind - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-bind.git - - prefix: roles/cloud_init - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-cloud_init.git - - prefix: roles/composer - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-composer.git - - prefix: roles/cron - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-cron.git - - prefix: roles/deploy - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-deploy.git - - prefix: roles/dhcp - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-dhcp.git - - prefix: roles/dnsmasq - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-dnsmasq.git - - prefix: roles/docker - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-docker.git - - prefix: roles/elasticsearch - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-elasticsearch.git - - prefix: roles/environment - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-environment.git - - prefix: roles/fail2ban - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-fail2ban.git - - prefix: roles/files - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-files.git - - prefix: roles/git - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-git.git - - prefix: roles/gitlab - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-gitlab.git - - prefix: roles/glusterfs - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-glusterfs.git - - prefix: roles/grafana - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-grafana.git - - prefix: roles/graylog_sidecar - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-graylog_sidecar.git - - prefix: roles/haproxy - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-haproxy.git - # Deprecated - #- prefix: roles/heka - # target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-heka.git - - prefix: roles/hugo - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-hugo.git - - prefix: roles/influxdb - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-influxdb.git - - prefix: roles/java - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-java.git - - prefix: roles/keepalived - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-keepalived.git - - prefix: roles/kernel - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-kernel.git - - prefix: roles/locales - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-locales.git - - prefix: roles/logentries - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-logentries.git - - prefix: roles/logrotate - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-logrotate.git - - prefix: roles/mailhog - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-mailhog.git - - prefix: roles/make - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-make.git - - prefix: roles/maxscale - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-maxscale.git - - prefix: roles/merge - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-merge.git - - prefix: roles/mongo_express - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-mongo_express.git - - prefix: roles/mongodb - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-mongodb.git - - prefix: roles/motd - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-motd.git - - prefix: roles/mount - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-mount.git - - prefix: roles/mysql - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-mysql.git - - prefix: roles/network - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-network.git - - prefix: roles/nginx - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-nginx.git - - prefix: roles/ngrok - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-ngrok.git - - prefix: roles/nodejs - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-nodejs.git - - prefix: roles/npm - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-npm.git - - prefix: roles/ntp - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-ntp.git - - prefix: roles/oauth2_proxy - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-oauth2_proxy.git - - prefix: roles/ohmyzsh - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-ohmyzsh.git - - prefix: roles/opcache_dashboard - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-opcache_dashboard.git - - prefix: roles/pam_ssh_agent_auth - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-pam_ssh_agent_auth.git - - prefix: roles/phantomjs - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-phantomjs.git - - prefix: roles/php - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-php.git - - prefix: roles/phpmyadmin - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-phpmyadmin.git - - prefix: roles/phppgadmin - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-phppgadmin.git - - prefix: roles/phpredisadmin - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-phpredisadmin.git - - prefix: roles/postgresql - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-postgresql.git - - prefix: roles/proftpd - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-proftpd.git - - prefix: roles/proxmox - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-proxmox.git - - prefix: roles/redis - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-redis.git - - prefix: roles/rsyslog - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-rsyslog.git - # Deprecated - #- prefix: roles/rtail - # target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-rtail.git - - prefix: roles/sensu - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-sensu.git - - prefix: roles/sensu_go - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-sensu_go.git - - prefix: roles/shorewall - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-shorewall.git - - prefix: roles/skeleton - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-skeleton.git - - prefix: roles/sqlite - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-sqlite.git - - prefix: roles/ssh - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-ssh.git - - prefix: roles/sudo - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-sudo.git - - prefix: roles/supervisor - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-supervisor.git - - prefix: roles/systemd - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-systemd.git - - prefix: roles/telegraf - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-telegraf.git - - prefix: roles/thumbor - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-thumbor.git - - prefix: roles/timezone - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-timezone.git - - prefix: roles/varnish - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-varnish.git - - prefix: roles/vault - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-vault.git - - prefix: roles/vim - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-vim.git - - prefix: roles/yarn - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-yarn.git - - prefix: roles/zsh - target: https://${GITSPLIT_GITHUB_API_TOKEN}@github.com/manala/ansible-role-zsh.git - -# List of references to split (defined as regexp) -origins: - - ^master$ diff --git a/.manala/make/Makefile b/.manala/make/Makefile deleted file mode 100644 index d7c28941a..000000000 --- a/.manala/make/Makefile +++ /dev/null @@ -1,141 +0,0 @@ -.PHONY: lint test split sync collection - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.travis \ - $(MANALA_MAKE_DIR)/Makefile.gitsplit \ - $(MANALA_MAKE_DIR)/Makefile.collection - --include \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######### -# Roles # -######### - -ROLES_ALL = $(filter-out $(ROLES_DEPRECATED),$(sort $(patsubst roles/%/,%,$(wildcard roles/*/)))) -ROLES_DIFF = $(filter-out $(ROLES_DEPRECATED),$(sort $(shell git diff --name-only $(TRAVIS_COMMIT_RANGE)| grep "^roles/" | cut -d/ -f2))) - -############# -# Partition # -############# - -PART ?= 1/1 - -PARTITION_PART := $(call list_split_first,/,$(PART)) -PARTITION_PARTS := $(call list_split_last,/,$(PART)) - -######## -# Lint # -######## - -MANALA_HELP += $(LINT_HELP)\n - -LINT_HELP = \ - $(call help_section,Lint) \ - $(call help,Lint, Lint roles) - -lint: - $(call list_loop,ROLE,$(call list_partition,$(PARTITION_PART),$(PARTITION_PARTS),$(if $(ROLES),$(ROLES),$(ROLES_ALL))), \ - $$(call if_in,$$(ROLE),$$(ROLES_ALL), \ - $$(MAKE) --silent --directory=roles/$$(ROLE) lint, \ - $$(call log_error,Role \"$$(ROLE)\" is not available) ; exit 1 \ - ), \ - TRAVIS_FOLD \ - ) - -LINT_HELP += $(call help,lint.diff,Lint roles - Diff) -lint.diff: ROLES = $(ROLES_DIFF) -lint.diff: lint - -######## -# Test # -######## - -MANALA_HELP += $(TEST_HELP)\n - -TEST_HELP = \ - $(call help_section,Test) \ - $(call help,test, Test roles) - -test: - $(call list_loop,ROLE,$(call list_partition,$(PARTITION_PART),$(PARTITION_PARTS),$(if $(ROLES),$(ROLES),$(ROLES_ALL))), \ - $$(call if_in,$$(ROLE),$$(ROLES_ALL), \ - $$(MAKE) --silent --directory=roles/$$(ROLE) test, \ - $$(call log_error,Role \"$$(ROLE)\" is not available) ; exit 1 \ - ) \ - ) - -TEST_HELP += $(call help,test.diff,Test roles - Diff) -test.diff: ROLES = $(ROLES_DIFF) -test.diff: test - -######### -# Split # -######### - -MANALA_HELP += $(SPLIT_HELP)\n - -SPLIT_HELP = \ - $(call help_section,Split) \ - $(call help,split,Split ansible roles) - -split: - $(call confirm,Please confirm split of *ALL* ansible roles) - $(call gitsplit) - -######## -# Sync # -######## - -MANALA_HELP += $(SYNC_HELP)\n - -SYNC_HELP = \ - $(call help_section,Sync) \ - $(call help,sync,Sync roles) - -sync: - $(call fail_if_not,$(FROM),FROM is empty or not set) - $(call confirm,Please confirm sync from \"$(FROM)\" ansible role) - for ROLE in roles/*; do \ - echo $$ROLE | cut -d/ -f2; \ - cp roles/$$FROM/.gitignore $$ROLE; \ - cp roles/$$FROM/.travis.yml $$ROLE; \ - cp -r roles/$$FROM/.manala $$ROLE; \ - done - -############## -# Collection # -############## - -MANALA_COLLECTION = manala-roles-*.tar.gz - -MANALA_HELP += $(COLLECTION_HELP) - -COLLECTION_HELP = \ - $(call help_section,Collection) \ - -define collection - $(call docker_collection, ansible-galaxy collection $(1)) -endef - -collection.prepare: - ./prepare_collection.py -COLLECTION_HELP +=$(call help,collection.prepare,Prepare collection) \ - -collection.build: - rm -rf $(MANALA_COLLECTION) - $(call collection,build collection --force --verbose) -COLLECTION_HELP +=$(call help,collection.build, Create collection) \ - -collection.publish: - $(call collection,publish $(MANALA_COLLECTION) --api-key $(COLLECTION_API_TOKEN)) -COLLECTION_HELP += $(call help,collection.publish,Publish collection) diff --git a/.manala/make/Makefile.collection b/.manala/make/Makefile.collection deleted file mode 100644 index 95ebc801c..000000000 --- a/.manala/make/Makefile.collection +++ /dev/null @@ -1,9 +0,0 @@ -define docker_collection - docker run \ - --rm \ - --env COLLECTION_API_TOKEN \ - --volume $(PWD):/srv/ \ - --workdir /srv/ \ - manala/ansible:edge \ - $(1) -endef diff --git a/.manala/make/Makefile.gitsplit b/.manala/make/Makefile.gitsplit deleted file mode 100644 index 44af4e068..000000000 --- a/.manala/make/Makefile.gitsplit +++ /dev/null @@ -1,24 +0,0 @@ -############# -# Functions # -############# - -ifeq ($(shell uname -s),Darwin) -define gitsplit - docker run \ - --rm \ - --tty --interactive \ - --env GITSPLIT_GITHUB_API_TOKEN \ - --volume $(MANALA_CURRENT_DIR):/srv \ - jderusse/gitsplit -endef -else -define gitsplit - docker run \ - --rm \ - --tty --interactive \ - --env GITSPLIT_GITHUB_API_TOKEN \ - --volume $(MANALA_CURRENT_DIR):/srv \ - jderusse/gitsplit - --ref "${TRAVIS_BRANCH}" -endef -endif diff --git a/.manala/make/Makefile.manala b/.manala/make/Makefile.manala deleted file mode 100644 index 5395cc7a9..000000000 --- a/.manala/make/Makefile.manala +++ /dev/null @@ -1,403 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - $(if $(CONFIRM),, \ - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" \ - ) -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/.manala/make/Makefile.travis b/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/.manala/make/gmsl/__gmsl b/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/.manala/make/gmsl/gmsl b/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 01439d021..000000000 --- a/.travis.yml +++ /dev/null @@ -1,92 +0,0 @@ -language: generic - -services: - - docker - -branches: - only: - - master - -env: - global: - - VERBOSE=1 - -jobs: - include: - - &lint-test - stage: lint & test - script: make lint.diff && make test.diff - if: type = pull_request - env: - - DISTRIBUTIONS=debian.jessie ANSIBLE_VERSION=2.6.5 PART=1/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.jessie ANSIBLE_VERSION=2.6.5 PART=2/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.jessie ANSIBLE_VERSION=2.6.5 PART=3/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.jessie ANSIBLE_VERSION=2.6.5 PART=4/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.jessie ANSIBLE_VERSION=2.6.5 PART=5/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.jessie ANSIBLE_VERSION=2.6.5 PART=6/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.jessie ANSIBLE_VERSION=2.6.5 PART=7/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.stretch ANSIBLE_VERSION=2.6.5 PART=1/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.stretch ANSIBLE_VERSION=2.6.5 PART=2/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.stretch ANSIBLE_VERSION=2.6.5 PART=3/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.stretch ANSIBLE_VERSION=2.6.5 PART=4/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.stretch ANSIBLE_VERSION=2.6.5 PART=5/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.stretch ANSIBLE_VERSION=2.6.5 PART=6/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.stretch ANSIBLE_VERSION=2.6.5 PART=7/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.buster ANSIBLE_VERSION=2.6.5 PART=1/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.buster ANSIBLE_VERSION=2.6.5 PART=2/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.buster ANSIBLE_VERSION=2.6.5 PART=3/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.buster ANSIBLE_VERSION=2.6.5 PART=4/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.buster ANSIBLE_VERSION=2.6.5 PART=5/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.buster ANSIBLE_VERSION=2.6.5 PART=6/7 - - <<: *lint-test - env: - - DISTRIBUTIONS=debian.buster ANSIBLE_VERSION=2.6.5 PART=7/7 - - stage: gitsplit - script: - - git config remote.origin.fetch "+refs/*:refs/*" - - git config remote.origin.mirror true - - git fetch --prune --unshallow || git fetch --prune - - make split CONFIRM=1 - if: branch = master AND type = push - -notifications: - slack: - secure: eLmB7407GORDp/9w55mwWm6slUHDdd6zamFOvfUBzu0EE2D3hnMnL6rebjQy+TXy5J0MAHokpMoldHCgfrOnr9Nj8orntGVDV8waIyMekEV55dbPFspW/skDE9Hq2d+NL1U5sDg57P4QzrKJ12msvFyed4wih+YFvhAUX419VKYzjQsj+XMqnsem0oOktpNoKENrOQM6GmNZSGG+Kjgg1XfybRNvEUN6mkBnbJH+SZCM0h/rNnluJItLjXiGG4ExZoKRdSOgb9ugjSSkTOu/x2tgdroKbtZhlYAbEuYCRugPfK/wCWmn6RfLfGjwDvbII7HHbjQ05vYe6BpbIERJhv5uSIg9YCJrunasEBHDG0C3wNWoEdeTwEE8YdFFbX2PiI21TT8FBD3ketLntgPOycya+Il2jBc51I1dQ7aA11E433YtCQyQVpV0Mywhy3Ra6t5nnOjyfG0DGwIrl5YqUgwah44dh96go9X2k75nLguD5q4bXE36th36x6VXp/4SBQg/15EWJhV1cRA+ypuIXV5Tiyvi9cxHmkdW8APSBUWo1ow3O3Q35gF4OYJvwc0ndqf81OfmWEAjeazIJTdO8xqxr+0dtP4WZ/lv+a+T9xwVqhAje+c4AYS8l5Yr887RjCzZtpW1NJGzH35Zu6BtB4Yh4gdoBJiGrN/gC/tK/Wg= diff --git a/CHANGELOG.md b/CHANGELOG.md index f5bd70367..0c939c263 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,65 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Added +- [Php] 8.1 support + +## [Unreleased] +### Added +- [All] Add debian bullseye support +- [Accounts] `ignore` users state +- [Accounts] users short syntax +- [Accounts] `ignore` groups state + +### Fixed +- [Apt] Percona key url +- [Cron] Remove empty lines between jobs +- [MongoDB] `python-pymongo` or `python3-pymongo` apt package as requirements for users handling, depending of tha ansible python version +- [ProFTPd] Remove useless leading spaces in users password file + +### Removed +- [All] Remove debian jessie support +- [Ansible Galaxy] Remove alternatives support +- [Apt] Remove deprecated `debian_security` `debian_security_src` `debian_updates` `debian_updates_src` `debian_backports` `dotdeb` `maxscale_2_2_6` `sury_php_debian` repositories patterns +- [Apt] Remove deprecated `sury_php_debian` keys patterns +- [Apt] Remove debian jessie related `mariadb_10_0`, `elasticsearch_1_7`, `nodesource_0_10`, `nodesource_0_12`, `nodesource_5` repositories patterns +- [Apt] Remove debian jessie related `mariadb_legacy` keys patterns +- [Apt] Remove `php5-*` preferences pattern +- [Apt] Remove deprecated `phpmyadmin`, `phppgadmin`, `oauth2-proxy`, `thefuck`, and `httpie` preferences pattern, all related to deprecated manala debian packages +- [Apt] Remove 'logentries' repository, key, and preference patterns (no more available) +- [Apt] Remove 'sensu' repository, key, and preference patterns (no more available) +- [Beanstalkd] Remove role +- [Elasticsearch] debian jessie related version 1.7 support +- [Grafana] Remove versions 2.0/2.1/2.5 support +- [Graylog Sidecar] Remove role +- [Heka] Remove role +- [Hugo] Remove role +- [Logentries] Remove role +- [Merge] Remove role +- [Mongo Express] Remove role +- [OAuth2 Proxy] Remove role +- [Timezone] Stop using handlers +- [Mailhog] Remove role +- [Nginx] Remove config filters +- [Opcache Dashboard] Remove role +- [PhantomJS] Remove role +- [PhpMyAdmin] Remove role +- [PhpPgAdmin] Remove role +- [PhpRedisAdmin] Remove role +- [Proxmox] Remove role +- [Redis] Remove version 2.8 support +- [Rtail] Remove role +- [Vault] Remove role +- [Varnish] Remove role + +### Changed +- [Apt] Don't ensure anymore that configs (`/etc/apt/apt.conf.d`) and preferences (`/etc/apt/preferences.d`) directory exists +- [Apt] Switch default preferences pin priority from 900 to 1000 +- [Apt] Use regular expressions in preferences patterns when possible (such as `php`) +- [OhMyZsh] Update users template (see: https://github.com/ohmyzsh/ohmyzsh/commits/master/templates/zshrc.zsh-template) +- [Grafana] Group services handling and stop using handlers +- [Shorewall] Explicit config file permissions +- [Systemd] Use native systemd module for `daemon-reload` ## [0.1.141] - 2021-12-10 ### Added diff --git a/Makefile b/Makefile index 5ffbccba1..e6e6f659d 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,95 @@ .SILENT: +ANSIBLE_COLLECTION=roles +ANSIBLE_NAMESPACE=manala +ANSIBLE_IMAGE=quay.io/ansible/toolset:3.5.0 + +-include \ + ./.env + ########## -# Manala # +# Docker # ########## -include .manala/make/Makefile +define docker_run + docker run \ + --rm \ + --tty \ + --interactive \ + --hostname ansible \ + --mount 'type=bind,source=$(CURDIR),target=/srv/ansible_collections/$(ANSIBLE_NAMESPACE)/$(ANSIBLE_COLLECTION)' \ + --mount 'type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock' \ + --workdir /srv/ansible_collections/$(ANSIBLE_NAMESPACE)/$(ANSIBLE_COLLECTION) \ + $(ANSIBLE_IMAGE) \ + $(strip $(1)) +endef + +define docker_collection + docker run \ + --rm \ + --env COLLECTION_API_TOKEN \ + --volume $(PWD):/srv/ \ + --workdir /srv/ \ + $(ANSIBLE_IMAGE) \ + $(1) +endef + +###### +# Sh # +###### + +sh: + $(call docker_run) +.PHONY: sh + +######## +# Lint # +######## + +lint: + $(call docker_run, ansible-lint) +.PHONY: lint + +######## +# Test # +######## + +test: test.sanity test.units +.PHONY: test + +test.sanity: + $(call docker_run, ansible-test sanity --python 3.8 --requirements --verbose --color) +.PHONY: test.sanity + +test.units: + $(call docker_run, ansible-test units --python 3.8 --requirements --verbose --color) +.PHONY: test.units + +############ +# Molecule # +############ + +molecule: + $(call docker_run, molecule test --all) + $(call docker_run, molecule test \ + $(if $(ROLE),--scenario-name $(ROLE),--all)) +.PHONY: molecule + +############## +# Collection # +############## + +MANALA_COLLECTION = $(ANSIBLE_NAMESPACE)-$(ANSIBLE_COLLECTION)-*.tar.gz + +define collection + $(call docker_collection, ansible-galaxy collection $(1)) +endef -######### -# Roles # -######### +collection.build: + rm -rf $(MANALA_COLLECTION) + $(call collection,build --force --verbose) +.PHONY: collection.build -ROLES_DEPRECATED = \ - heka \ - rtail +collection.publish: + $(call collection,publish $(MANALA_COLLECTION) --api-key $(COLLECTION_API_TOKEN)) +.PHONY: collection.publish diff --git a/README.md b/README.md index ccea1aca9..a2376a251 100644 --- a/README.md +++ b/README.md @@ -1,107 +1,85 @@ -# Ansible Roles - -## Details - -**Note:** The ~~crossed out~~ roles are considered deprecated. - -| Role | Description | Build Status | Latest Stable Version | -| :--- | :--- | :---: | :---: | -| [accounts](https://github.com/manala/ansible-role-accounts) | Ansible role dealing with the setup of users and groups accounts and ssh keys. | [![Build Status](https://travis-ci.org/manala/ansible-role-accounts.svg?branch=master)](https://travis-ci.org/manala/ansible-role-accounts) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-accounts.svg)](https://img.shields.io/github/release/manala/ansible-role-accounts.svg) | -| [alternatives](https://github.com/manala/ansible-role-alternatives) | This role will deal with the setup of __alternatives__. | [![Build Status](https://travis-ci.org/manala/ansible-role-alternatives.svg?branch=master)](https://travis-ci.org/manala/ansible-role-alternatives) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-alternatives.svg)](https://img.shields.io/github/release/manala/ansible-role-alternatives.svg) | -| [ansible](https://github.com/manala/ansible-role-ansible) | This role will deal with the setup and the config of [Ansible](https://www.ansible.com/). | [![Build Status](https://travis-ci.org/manala/ansible-role-ansible.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ansible) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-ansible.svg)](https://img.shields.io/github/release/manala/ansible-role-ansible.svg) | -| [ansible_galaxy](https://github.com/manala/ansible-role-ansible_galaxy) | This role will deal with the setup of __Ansible Galaxy__. | [![Build Status](https://travis-ci.org/manala/ansible-role-ansible_galaxy.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ansible_galaxy) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-ansible_galaxy.svg)](https://img.shields.io/github/release/manala/ansible-role-ansible_galaxy.svg) | -| [apparmor](https://github.com/manala/ansible-role-apparmor) | This role will deal with the setup of AppArmor. | [![Build Status](https://travis-ci.org/manala/ansible-role-apparmor.svg?branch=master)](https://travis-ci.org/manala/ansible-role-apparmor) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-apparmor.svg)](https://img.shields.io/github/release/manala/ansible-role-apparmor.svg) | -| [apt](https://github.com/manala/ansible-role-apt) | This role will add third party sources to the package manager. | [![Build Status](https://travis-ci.org/manala/ansible-role-apt.svg?branch=master)](https://travis-ci.org/manala/ansible-role-apt) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-apt.svg)](https://img.shields.io/github/release/manala/ansible-role-apt.svg) | -| [aptly](https://github.com/manala/ansible-role-aptly) | This role will deal with the setup of [Aptly](https://www.aptly.info/). | [![Build Status](https://travis-ci.org/manala/ansible-role-aptly.svg?branch=master)](https://travis-ci.org/manala/ansible-role-aptly) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-aptly.svg)](https://img.shields.io/github/release/manala/ansible-role-aptly.svg) | -| [backup_manager](https://github.com/manala/ansible-role-backup_manager) | This role will deal with the setup of [Backup Manager](https://github.com/sukria/Backup-Manager). | [![Build Status](https://travis-ci.org/manala/ansible-role-backup_manager.svg?branch=master)](https://travis-ci.org/manala/ansible-role-backup_manager) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-backup_manager.svg)](https://img.shields.io/github/release/manala/ansible-role-backup_manager.svg) | -| [beanstalkd](https://github.com/manala/ansible-role-beanstalkd) | This role will deal with the setup of [Beanstalkd](http://kr.github.io/beanstalkd/). | [![Build Status](https://travis-ci.org/manala/ansible-role-beanstalkd.svg?branch=master)](https://travis-ci.org/manala/ansible-role-beanstalkd) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-beanstalkd.svg)](https://img.shields.io/github/release/manala/ansible-role-beanstalkd.svg) | -| [bind](https://github.com/manala/ansible-role-bind) | This role will deal with the setup of [Bind](https://www.isc.org/downloads/bind/). | [![Build Status](https://travis-ci.org/manala/ansible-role-bind.svg?branch=master)](https://travis-ci.org/manala/ansible-role-bind) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-bind.svg)](https://img.shields.io/github/release/manala/ansible-role-bind.svg) | -| [cloud_init](https://github.com/manala/ansible-role-cloud_init) | This role will deal with the configuration of [Cloud-init](https://cloud-init.io/). | [![Build Status](https://travis-ci.org/manala/ansible-role-cloud_init.svg?branch=master)](https://travis-ci.org/manala/ansible-role-cloud_init) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-cloud_init.svg)](https://img.shields.io/github/release/manala/ansible-role-cloud_init.svg) | -| [composer](https://github.com/manala/ansible-role-composer) | This role will deal with the setup of [Composer](https://getcomposer.org) | [![Build Status](https://travis-ci.org/manala/ansible-role-composer.svg?branch=master)](https://travis-ci.org/manala/ansible-role-composer) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-composer.svg)](https://img.shields.io/github/release/manala/ansible-role-composer.svg) | -| [cron](https://github.com/manala/ansible-role-cron) | This role will deal with the setup of __Cron__. | [![Build Status](https://travis-ci.org/manala/ansible-role-cron.svg?branch=master)](https://travis-ci.org/manala/ansible-role-cron) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-cron.svg)](https://img.shields.io/github/release/manala/ansible-role-cron.svg) | -| [deploy](https://github.com/manala/ansible-role-deploy) | This role will deal with __Deployment__. | [![Build Status](https://travis-ci.org/manala/ansible-role-deploy.svg?branch=master)](https://travis-ci.org/manala/ansible-role-deploy) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-deploy.svg)](https://img.shields.io/github/release/manala/ansible-role-deploy.svg) | -| [dhcp](https://github.com/manala/ansible-role-dhcp) | This role will deal with the setup of [ISC DHCP Server](https://www.isc.org/downloads/dhcp/). | [![Build Status](https://travis-ci.org/manala/ansible-role-dhcp.svg?branch=master)](https://travis-ci.org/manala/ansible-role-dhcp) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-dhcp.svg)](https://img.shields.io/github/release/manala/ansible-role-dhcp.svg) | -| [dnsmasq](https://github.com/manala/ansible-role-dnsmasq) | This role will deal with the setup of [Dnsmasq](http://www.thekelleys.org.uk/dnsmasq/doc.html). | [![Build Status](https://travis-ci.org/manala/ansible-role-dnsmasq.svg?branch=master)](https://travis-ci.org/manala/ansible-role-dnsmasq) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-dnsmasq.svg)](https://img.shields.io/github/release/manala/ansible-role-dnsmasq.svg) | -| [docker](https://github.com/manala/ansible-role-docker) | This role will deal with the setup of [Docker](https://www.docker.com/). | [![Build Status](https://travis-ci.org/manala/ansible-role-docker.svg?branch=master)](https://travis-ci.org/manala/ansible-role-docker) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-docker.svg)](https://img.shields.io/github/release/manala/ansible-role-docker.svg) | -| [elasticsearch](https://github.com/manala/ansible-role-elasticsearch) | This role will deal with the setup of [Elasticsearch](https://www.elastic.co/fr/products/elasticsearch). | [![Build Status](https://travis-ci.org/manala/ansible-role-elasticsearch.svg?branch=master)](https://travis-ci.org/manala/ansible-role-elasticsearch) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-elasticsearch.svg)](https://img.shields.io/github/release/manala/ansible-role-elasticsearch.svg) | -| [environment](https://github.com/manala/ansible-role-environment) | This role will deal with the setup of environment variables. | [![Build Status](https://travis-ci.org/manala/ansible-role-environment.svg?branch=master)](https://travis-ci.org/manala/ansible-role-environment) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-environment.svg)](https://img.shields.io/github/release/manala/ansible-role-environment.svg) | -| [fail2ban](https://github.com/manala/ansible-role-fail2ban) | This role will deal with the setup and config of [Fail2Ban](https://www.fail2ban.org/wiki/index.php/Main_Page). | [![Build Status](https://travis-ci.org/manala/ansible-role-fail2ban.svg?branch=master)](https://travis-ci.org/manala/ansible-role-fail2ban) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-fail2ban.svg)](https://img.shields.io/github/release/manala/ansible-role-fail2ban.svg) | -| [files](https://github.com/manala/ansible-role-files) | This role will deal with the attributes of files. | [![Build Status](https://travis-ci.org/manala/ansible-role-files.svg?branch=master)](https://travis-ci.org/manala/ansible-role-files) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-files.svg)](https://img.shields.io/github/release/manala/ansible-role-files.svg) | -| [git](https://github.com/manala/ansible-role-git) | This role will deal with the setup and configuration of git. | [![Build Status](https://travis-ci.org/manala/ansible-role-git.svg?branch=master)](https://travis-ci.org/manala/ansible-role-git) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-git.svg)](https://img.shields.io/github/release/manala/ansible-role-git.svg) | -| [gitlab](https://github.com/manala/ansible-role-gitlab) | This role will assume the setup of [Gitlab](https://about.gitlab.com/). | [![Build Status](https://travis-ci.org/manala/ansible-role-gitlab.svg?branch=master)](https://travis-ci.org/manala/ansible-role-gitlab) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-gitlab.svg)](https://img.shields.io/github/release/manala/ansible-role-gitlab.svg) | -| [gomplate](https://github.com/manala/ansible-roles/tree/master/roles/gomplate) | This role will deal with the setup of [Gomplate](https://github.com/hairyhenderson/gomplate/releases). | - | - | -| [glusterfs](https://github.com/manala/ansible-role-glusterfs) | This role will assume the setup of [GlusterFS](https://www.gluster.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-glusterfs.svg?branch=master)](https://travis-ci.org/manala/ansible-role-glusterfs) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-glusterfs.svg)](https://img.shields.io/github/release/manala/ansible-role-glusterfs.svg) | -| [grafana](https://github.com/manala/ansible-role-grafana) | This role will deal with the configuration of [Grafana](http://grafana.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-grafana.svg?branch=master)](https://travis-ci.org/manala/ansible-role-grafana) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-grafana.svg)](https://img.shields.io/github/release/manala/ansible-role-grafana.svg) | -| [graylog_sidecar](https://github.com/manala/ansible-role-graylog_sidecar) | This role will deal with the configuration of [Graylog_sidecar](https://github.com/Graylog2/collector-sidecar). | [![Build Status](https://travis-ci.org/manala/ansible-role-graylog_sidecar.svg?branch=master)](https://travis-ci.org/manala/ansible-role-graylog_sidecar) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-graylog_sidecar.svg)](https://img.shields.io/github/release/manala/ansible-role-graylog_sidecar.svg) | -| [haproxy](https://github.com/manala/ansible-role-haproxy) | This role will deal with the setup of [HAProxy](http://www.haproxy.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-haproxy.svg?branch=master)](https://travis-ci.org/manala/ansible-role-haproxy) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-haproxy.svg)](https://img.shields.io/github/release/manala/ansible-role-haproxy.svg) | -| ~~[heka](https://github.com/manala/ansible-role-heka)~~ | ~~This role will deal with the install and setup of [Heka](https://github.com/mozilla-services/heka).~~ | [![Build Status](https://travis-ci.org/manala/ansible-role-heka.svg?branch=master)](https://travis-ci.org/manala/ansible-role-heka) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-heka.svg)](https://img.shields.io/github/release/manala/ansible-role-heka.svg) | -| [hugo](https://github.com/manala/ansible-role-hugo) | This role will deal with the setup of [Hugo](https://gohugo.io/). | [![Build Status](https://travis-ci.org/manala/ansible-role-hugo.svg?branch=master)](https://travis-ci.org/manala/ansible-role-hugo) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-hugo.svg)](https://img.shields.io/github/release/manala/ansible-role-hugo.svg) | -| [influxdb](https://github.com/manala/ansible-role-influxdb) | This role will assume the setup of [InfluxDB](https://www.influxdata.com/time-series-platform/influxdb/). | [![Build Status](https://travis-ci.org/manala/ansible-role-influxdb.svg?branch=master)](https://travis-ci.org/manala/ansible-role-influxdb) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-influxdb.svg)](https://img.shields.io/github/release/manala/ansible-role-influxdb.svg) | -| [java](https://github.com/manala/ansible-role-java) | This role will deal with the setup of __java__. | [![Build Status](https://travis-ci.org/manala/ansible-role-java.svg?branch=master)](https://travis-ci.org/manala/ansible-role-java) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-java.svg)](https://img.shields.io/github/release/manala/ansible-role-java.svg) | -| [keepalived](https://github.com/manala/ansible-role-keepalived) | This role will deal with the setup and the configuration of [Keepalived](http://www.keepalived.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-keepalived.svg?branch=master)](https://travis-ci.org/manala/ansible-role-keepalived) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-keepalived.svg)](https://img.shields.io/github/release/manala/ansible-role-keepalived.svg) | -| [kernel](https://github.com/manala/ansible-role-kernel) | This role will assume the setup of kernel. | [![Build Status](https://travis-ci.org/manala/ansible-role-kernel.svg?branch=master)](https://travis-ci.org/manala/ansible-role-kernel) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-kernel.svg)](https://img.shields.io/github/release/manala/ansible-role-kernel.svg) | -| [locales](https://github.com/manala/ansible-role-locales) | This role will deal with the configuration of system __locales__. | [![Build Status](https://travis-ci.org/manala/ansible-role-locales.svg?branch=master)](https://travis-ci.org/manala/ansible-role-locales) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-locales.svg)](https://img.shields.io/github/release/manala/ansible-role-locales.svg) | -| [logentries](https://github.com/manala/ansible-role-logentries) | This role will deal with the configuration of [Logentries](https://logentries.com/). | [![Build Status](https://travis-ci.org/manala/ansible-role-logentries.svg?branch=master)](https://travis-ci.org/manala/ansible-role-logentries) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-logentries.svg)](https://img.shields.io/github/release/manala/ansible-role-logentries.svg) | -| [logrotate](https://github.com/manala/ansible-role-logrotate) | This role will assume the setup of Logrotate. | [![Build Status](https://travis-ci.org/manala/ansible-role-logrotate.svg?branch=master)](https://travis-ci.org/manala/ansible-role-logrotate) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-logrotate.svg)](https://img.shields.io/github/release/manala/ansible-role-logrotate.svg) | -| [mailhog](https://github.com/manala/ansible-role-mailhog) | This role will deal with the setup and the config of [Mailhog](https://github.com/mailhog/MailHog). | [![Build Status](https://travis-ci.org/manala/ansible-role-mailhog.svg?branch=master)](https://travis-ci.org/manala/ansible-role-mailhog) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-mailhog.svg)](https://img.shields.io/github/release/manala/ansible-role-mailhog.svg) | -| [make](https://github.com/manala/ansible-role-make) | This role will deal with the setup of __make__. | [![Build Status](https://travis-ci.org/manala/ansible-role-make.svg?branch=master)](https://travis-ci.org/manala/ansible-role-make) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-make.svg)](https://img.shields.io/github/release/manala/ansible-role-make.svg) | -| [maxscale](https://github.com/manala/ansible-role-maxscale) | This role will deal with the setup and configuration of [Maxscale](https://mariadb.com/products/technology/maxscale). | [![Build Status](https://travis-ci.org/manala/ansible-role-maxscale.svg?branch=master)](https://travis-ci.org/manala/ansible-role-maxscale) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-maxscale.svg)](https://img.shields.io/github/release/manala/ansible-role-maxscale.svg) | -| [merge](https://github.com/manala/ansible-role-merge) | This role will deal with the merging of ansible variables. | [![Build Status](https://travis-ci.org/manala/ansible-role-merge.svg?branch=master)](https://travis-ci.org/manala/ansible-role-merge) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-merge.svg)](https://img.shields.io/github/release/manala/ansible-role-merge.svg) | -| [mongo_express](https://github.com/manala/ansible-role-mongo_express) | This role will deal with the setup and install of [Mongo Express](https://github.com/mongo-express/mongo-express). | [![Build Status](https://travis-ci.org/manala/ansible-role-mongo_express.svg?branch=master)](https://travis-ci.org/manala/ansible-role-mongo_express) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-mongo_express.svg)](https://img.shields.io/github/release/manala/ansible-role-mongo_express.svg) | -| [mongodb](https://github.com/manala/ansible-role-mongodb) | This role will deal with the setup of [Mongodb](https://www.mongodb.com/fr). | [![Build Status](https://travis-ci.org/manala/ansible-role-mongodb.svg?branch=master)](https://travis-ci.org/manala/ansible-role-mongodb) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-mongodb.svg)](https://img.shields.io/github/release/manala/ansible-role-mongodb.svg) | -| [motd](https://github.com/manala/ansible-role-motd) | This role will deal with the setup of Message Of The Day. | [![Build Status](https://travis-ci.org/manala/ansible-role-motd.svg?branch=master)](https://travis-ci.org/manala/ansible-role-motd) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-motd.svg)](https://img.shields.io/github/release/manala/ansible-role-motd.svg) | -| [mount](https://github.com/manala/ansible-role-mount) | This role will deal with the setup of mount points. | [![Build Status](https://travis-ci.org/manala/ansible-role-mount.svg?branch=master)](https://travis-ci.org/manala/ansible-role-mount) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-mount.svg)](https://img.shields.io/github/release/manala/ansible-role-mount.svg) | -| [mysql](https://github.com/manala/ansible-role-mysql) | This role will deal with the setup of [Mysql](https://www.mysql.com/). | [![Build Status](https://travis-ci.org/manala/ansible-role-mysql.svg?branch=master)](https://travis-ci.org/manala/ansible-role-mysql) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-mysql.svg)](https://img.shields.io/github/release/manala/ansible-role-mysql.svg) | -| [network](https://github.com/manala/ansible-role-network) | This role will handle network hosts, resolver and interfaces. | [![Build Status](https://travis-ci.org/manala/ansible-role-network.svg?branch=master)](https://travis-ci.org/manala/ansible-role-network) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-network.svg)](https://img.shields.io/github/release/manala/ansible-role-network.svg) | -| [nginx](https://github.com/manala/ansible-role-nginx) | This role will deal with the setup and config of [Nginx](https://nginx.org/en/). | [![Build Status](https://travis-ci.org/manala/ansible-role-nginx.svg?branch=master)](https://travis-ci.org/manala/ansible-role-nginx) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-nginx.svg)](https://img.shields.io/github/release/manala/ansible-role-nginx.svg) | -| [ngrok](https://github.com/manala/ansible-role-ngrok) | This role will deal with the setup and the config of [Ngrok](https://ngrok.com/). | [![Build Status](https://travis-ci.org/manala/ansible-role-ngrok.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ngrok) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-ngrok.svg)](https://img.shields.io/github/release/manala/ansible-role-ngrok.svg) | -| [nodejs](https://github.com/manala/ansible-role-nodejs) | This role will deal with the setup of [Nodejs](https://nodejs.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-nodejs.svg?branch=master)](https://travis-ci.org/manala/ansible-role-nodejs) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-nodejs.svg)](https://img.shields.io/github/release/manala/ansible-role-nodejs.svg) | -| [npm](https://github.com/manala/ansible-role-npm) | This role will deal with the handling of global npm packages. | [![Build Status](https://travis-ci.org/manala/ansible-role-npm.svg?branch=master)](https://travis-ci.org/manala/ansible-role-npm) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-npm.svg)](https://img.shields.io/github/release/manala/ansible-role-npm.svg) | -| [ntp](https://github.com/manala/ansible-role-ntp) | This role will deal with the setup of [Ntp](http://www.ntp.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-ntp.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ntp) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-ntp.svg)](https://img.shields.io/github/release/manala/ansible-role-ntp.svg) | -| [oauth2_proxy](https://github.com/manala/ansible-role-oauth2_proxy) | This role will deal with the setup and config of [OAuth2 Proxy](https://github.com/bitly/oauth2_proxy). | [![Build Status](https://travis-ci.org/manala/ansible-role-oauth2_proxy.svg?branch=master)](https://travis-ci.org/manala/ansible-role-oauth2_proxy) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-oauth2_proxy.svg)](https://img.shields.io/github/release/manala/ansible-role-oauth2_proxy.svg) | -| [ohmyzsh](https://github.com/manala/ansible-role-ohmyzsh) | This role will deal with the setup of [Oh My Zsh](http://ohmyz.sh/). | [![Build Status](https://travis-ci.org/manala/ansible-role-ohmyzsh.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ohmyzsh) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-ohmyzsh.svg)](https://img.shields.io/github/release/manala/ansible-role-ohmyzsh.svg) | -| [opcache_dashboard](https://github.com/manala/ansible-role-opcache_dashboard) | This role will deal with the setup and config of [OPcache Dashboard](https://github.com/carlosbuenosvinos/opcache-dashboard). | [![Build Status](https://travis-ci.org/manala/ansible-role-opcache_dashboard.svg?branch=master)](https://travis-ci.org/manala/ansible-role-opcache_dashboard) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-opcache_dashboard.svg)](https://img.shields.io/github/release/manala/ansible-role-opcache_dashboard.svg) | -| [pam_ssh_agent_auth](https://github.com/manala/ansible-role-pam_ssh_agent_auth) | This role will deal with the setup and config of [Pam ssh agent auth](http://pamsshagentauth.sourceforge.net/). | [![Build Status](https://travis-ci.org/manala/ansible-role-pam_ssh_agent_auth.svg?branch=master)](https://travis-ci.org/manala/ansible-role-pam_ssh_agent_auth) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-pam_ssh_agent_auth.svg)](https://img.shields.io/github/release/manala/ansible-role-pam_ssh_agent_auth.svg) | -| [phantomjs](https://github.com/manala/ansible-role-phantomjs) | This role will deal with the setup of [PhantomJS](http://phantomjs.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-phantomjs.svg?branch=master)](https://travis-ci.org/manala/ansible-role-phantomjs) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-phantomjs.svg)](https://img.shields.io/github/release/manala/ansible-role-phantomjs.svg) | -| [php](https://github.com/manala/ansible-role-php) | This role will deal with the setup and config of PHP. | [![Build Status](https://travis-ci.org/manala/ansible-role-php.svg?branch=master)](https://travis-ci.org/manala/ansible-role-php) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-php.svg)](https://img.shields.io/github/release/manala/ansible-role-php.svg) | -| [phpmyadmin](https://github.com/manala/ansible-role-phpmyadmin) | This role will deal with the setup and config of [PhpMyAdmin](https://www.phpmyadmin.net/). | [![Build Status](https://travis-ci.org/manala/ansible-role-phpmyadmin.svg?branch=master)](https://travis-ci.org/manala/ansible-role-phpmyadmin) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-phpmyadmin.svg)](https://img.shields.io/github/release/manala/ansible-role-phpmyadmin.svg) | -| [phppgadmin](https://github.com/manala/ansible-role-phppgadmin) | This role will deal with the setup and config of [PhpPgAdmin](http://phppgadmin.sourceforge.net/doku.php). | [![Build Status](https://travis-ci.org/manala/ansible-role-phppgadmin.svg?branch=master)](https://travis-ci.org/manala/ansible-role-phppgadmin) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-phppgadmin.svg)](https://img.shields.io/github/release/manala/ansible-role-phppgadmin.svg) | -| [phpredisadmin](https://github.com/manala/ansible-role-phpredisadmin) | This role will deal with the setup and config of [PhpRedisAdmin](https://github.com/erikdubbelboer/phpRedisAdmin). | [![Build Status](https://travis-ci.org/manala/ansible-role-phpredisadmin.svg?branch=master)](https://travis-ci.org/manala/ansible-role-phpredisadmin) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-phpredisadmin.svg)](https://img.shields.io/github/release/manala/ansible-role-phpredisadmin.svg) | -| [postgresql](https://github.com/manala/ansible-role-postgresql) | This role will deal with the setup of [PostgreSQL](http://www.postgresql.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-postgresql.svg?branch=master)](https://travis-ci.org/manala/ansible-role-postgresql) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-postgresql.svg)](https://img.shields.io/github/release/manala/ansible-role-postgresql.svg) | -| [proftpd](https://github.com/manala/ansible-role-proftpd) | This role will deal with the setup of [ProFTPd](http://www.proftpd.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-proftpd.svg?branch=master)](https://travis-ci.org/manala/ansible-role-proftpd) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-proftpd.svg)](https://img.shields.io/github/release/manala/ansible-role-proftpd.svg) | -| [proxmox](https://github.com/manala/ansible-role-proxmox) | This role will deal with the setup of [Proxmox](https://www.proxmox.com/en/). | [![Build Status](https://travis-ci.org/manala/ansible-role-proxmox.svg?branch=master)](https://travis-ci.org/manala/ansible-role-proxmox) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-proxmox.svg)](https://img.shields.io/github/release/manala/ansible-role-proxmox.svg) | -| [redis](https://github.com/manala/ansible-role-redis) | This role will deal with the setup of [Redis](https://redis.io/). | [![Build Status](https://travis-ci.org/manala/ansible-role-redis.svg?branch=master)](https://travis-ci.org/manala/ansible-role-redis) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-redis.svg)](https://img.shields.io/github/release/manala/ansible-role-redis.svg) | -| [rsyslog](https://github.com/manala/ansible-role-rsyslog) | This role will deal with the setup of [Rsyslog](http://www.rsyslog.com/). | [![Build Status](https://travis-ci.org/manala/ansible-role-rsyslog.svg?branch=master)](https://travis-ci.org/manala/ansible-role-rsyslog) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-rsyslog.svg)](https://img.shields.io/github/release/manala/ansible-role-rsyslog.svg) | -| ~~[rtail](https://github.com/manala/ansible-role-rtail)~~ | ~~This role will deal with the setup and install of [RTail](http://rtail.org/).~~ | [![Build Status](https://travis-ci.org/manala/ansible-role-rtail.svg?branch=master)](https://travis-ci.org/manala/ansible-role-rtail) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-rtail.svg)](https://img.shields.io/github/release/manala/ansible-role-rtail.svg) | -| [sensu](https://github.com/manala/ansible-role-sensu) | This role will deal with the setup of [Sensu](https://sensuapp.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-sensu.svg?branch=master)](https://travis-ci.org/manala/ansible-role-sensu) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-sensu.svg)](https://img.shields.io/github/release/manala/ansible-role-sensu.svg) | -| [sensu_go](https://github.com/manala/ansible-role-sensu_go) | This role will deal with the setup of [Sensu Go](https://sensu.io/). | [![Build Status](https://travis-ci.org/manala/ansible-role-sensu_go.svg?branch=master)](https://travis-ci.org/manala/ansible-role-sensu_go) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-sensu_go.svg)](https://img.shields.io/github/release/manala/ansible-role-sensu_go.svg) | -| [shorewall](https://github.com/manala/ansible-role-shorewall) | This role will assume the setup of [Shorewall](http://shorewall.net/). | [![Build Status](https://travis-ci.org/manala/ansible-role-shorewall.svg?branch=master)](https://travis-ci.org/manala/ansible-role-shorewall) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-shorewall.svg)](https://img.shields.io/github/release/manala/ansible-role-shorewall.svg) | -| [skeleton](https://github.com/manala/ansible-role-skeleton) | This role handle skeletons patterns and options. | [![Build Status](https://travis-ci.org/manala/ansible-role-skeleton.svg?branch=master)](https://travis-ci.org/manala/ansible-role-skeleton) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-skeleton.svg)](https://img.shields.io/github/release/manala/ansible-role-skeleton.svg) | -| [sqlite](https://github.com/manala/ansible-role-sqlite) | This role will deal with the setup of [SQLite](https://www.sqlite.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-sqlite.svg?branch=master)](https://travis-ci.org/manala/ansible-role-sqlite) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-sqlite.svg)](https://img.shields.io/github/release/manala/ansible-role-sqlite.svg) | -| [ssh](https://github.com/manala/ansible-role-ssh) | This role will deal with ssh configurations | [![Build Status](https://travis-ci.org/manala/ansible-role-ssh.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ssh) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-ssh.svg)](https://img.shields.io/github/release/manala/ansible-role-ssh.svg) | -| [sudo](https://github.com/manala/ansible-role-sudo) | This role will deal with the setup of Sudo. | [![Build Status](https://travis-ci.org/manala/ansible-role-sudo.svg?branch=master)](https://travis-ci.org/manala/ansible-role-sudo) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-sudo.svg)](https://img.shields.io/github/release/manala/ansible-role-sudo.svg) | -| [supervisor](https://github.com/manala/ansible-role-supervisor) | This role will deal with the setup of [Supervisor](http://supervisord.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-supervisor.svg?branch=master)](https://travis-ci.org/manala/ansible-role-supervisor) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-supervisor.svg)](https://img.shields.io/github/release/manala/ansible-role-supervisor.svg) | -| [symfony_cli](https://github.com/manala/ansible-roles/tree/master/roles/symfony_cli) | This role will deal with the setup of [Symfony Cli](https://symfony.com/download). | - | - | -| [systemd](https://github.com/manala/ansible-role-systemd) | This role will deal with the setup of Systemd. | [![Build Status](https://travis-ci.org/manala/ansible-role-systemd.svg?branch=master)](https://travis-ci.org/manala/ansible-role-systemd) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-systemd.svg)](https://img.shields.io/github/release/manala/ansible-role-systemd.svg) | -| [telegraf](https://github.com/manala/ansible-role-telegraf) | This role will deal with the setup and the config of [influxdata Telegraf](https://github.com/influxdata/telegraf). | [![Build Status](https://travis-ci.org/manala/ansible-role-telegraf.svg?branch=master)](https://travis-ci.org/manala/ansible-role-telegraf) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-telegraf.svg)](https://img.shields.io/github/release/manala/ansible-role-telegraf.svg) | -| [thumbor](https://github.com/manala/ansible-role-thumbor) | This role will deal with the setup and the config of [Thumbor](http://thumbor.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-thumbor.svg?branch=master)](https://travis-ci.org/manala/ansible-role-thumbor) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-thumbor.svg)](https://img.shields.io/github/release/manala/ansible-role-thumbor.svg) | -| [timezone](https://github.com/manala/ansible-role-timezone) | This role will deal with the setup of Timezone. | [![Build Status](https://travis-ci.org/manala/ansible-role-timezone.svg?branch=master)](https://travis-ci.org/manala/ansible-role-timezone) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-timezone.svg)](https://img.shields.io/github/release/manala/ansible-role-timezone.svg) | -| [varnish](https://github.com/manala/ansible-role-varnish) | This role will deal with the setup of [Varnish](https://varnish-cache.org/). | [![Build Status](https://travis-ci.org/manala/ansible-role-varnish.svg?branch=master)](https://travis-ci.org/manala/ansible-role-varnish) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-varnish.svg)](https://img.shields.io/github/release/manala/ansible-role-varnish.svg) | -| [vault](https://github.com/manala/ansible-role-vault) | This role will deal with the setup and configuration of [Hashicorp Vault server](https://www.vaultproject.io/). | [![Build Status](https://travis-ci.org/manala/ansible-role-vault.svg?branch=master)](https://travis-ci.org/manala/ansible-role-vault) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-vault.svg)](https://img.shields.io/github/release/manala/ansible-role-vault.svg) | -| [vim](https://github.com/manala/ansible-role-vim) | This role will deal with the setup and configuration of Vim. | [![Build Status](https://travis-ci.org/manala/ansible-role-vim.svg?branch=master)](https://travis-ci.org/manala/ansible-role-vim) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-vim.svg)](https://img.shields.io/github/release/manala/ansible-role-vim.svg) | -| [yarn](https://github.com/manala/ansible-role-yarn) | This role will deal with the setup of [Yarn](https://yarnpkg.com/). | [![Build Status](https://travis-ci.org/manala/ansible-role-yarn.svg?branch=master)](https://travis-ci.org/manala/ansible-role-yarn) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-yarn.svg)](https://img.shields.io/github/release/manala/ansible-role-yarn.svg) | -| [zsh](https://github.com/manala/ansible-role-zsh) | This role will deal with the setup of Zsh. | [![Build Status](https://travis-ci.org/manala/ansible-role-zsh.svg?branch=master)](https://travis-ci.org/manala/ansible-role-zsh) | [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-zsh.svg)](https://img.shields.io/github/release/manala/ansible-role-zsh.svg) | - -## Release +# Manala Collection for Ansible -``` -make release +[![homepage][image]][url] + +[image]: https://www.manala.io/images/manala.svg +[url]: https://www.manala.io/ "manala.io" + +**The flexible, robust, and web oriented toolbox for Ansible !** + +![Tests](https://img.shields.io/github/checks-status/manala/ansible-roles/master) + +## Using this collection + +### Installing the Collection from Ansible Galaxy + +Before using this collection, you need to install it with the Ansible Galaxy command-line tool: +```bash +ansible-galaxy collection install manala.roles ``` -### Set Chandler github api token +You can also include it in a `requirements.yml` file and install it with `ansible-galaxy collection install -r requirements.yml`, using the format: +```yaml +--- +collections: + - name: manala.roles ``` -export CHANDLER_GITHUB_API_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -travis login -travis repos --owner manala --active --no-interactive --match "manala/ansible-role-*" | xargs -n1 travis env set CHANDLER_GITHUB_API_TOKEN $CHANDLER_GITHUB_API_TOKEN --private --repo + +Note that if you install the collection from Ansible Galaxy, it will not be upgraded automatically when you upgrade the `ansible` package. To upgrade the collection to the latest available version, run the following command: +```bash +ansible-galaxy collection install manala.roles --upgrade ``` + +You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax to install version `0.1.0`: + +```bash +ansible-galaxy collection install manala.roles:==1.0.0 +``` +### Installing the Collection from Github + +In case of unavailability of ansible-galaxy, we host a tar.gz of every version of our collection on github: + - Check latest version available [here](https://github.com/manala/ansible-roles/releases) + - Use your prefered method: + + - cli: + ```bash + ansible-galaxy collection install https://github.com/manala/ansible-roles/releases/download/$VERSION/manala-roles-$VERSION.tar.gz + ``` + + - requirements.yaml: + ```yaml + collections: + + - name: https://github.com/manala/ansible-roles/releases/download/$VERSION/manala-roles-$VERSION.tar.gz + type: url + ``` + +See [Ansible Using collections](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html) for more details. + +## Release notes + +See the [changelog](https://github.com/manala/ansible-roles/blob/master/CHANGELOG.md). + +## Contributing to this collection +Found a bug ? Please open an [issue](https://github.com/manala/ansible-roles/issues) + +You can contact us [here](manala-io.slack.com) + +Any kind of contribution is very welcome, you can submit pull requests [here](https://github.com/manala/ansible-roles/pulls) + +## Continuous integration + +This collection uses [molecule](https://github.com/ansible-community/molecule), [ansible-lint](https://github.com/ansible-community/ansible-lint), and `ansible-test` for linting and testing roles. + +All of these tools are available through the excellent [ansible-toolset](https://github.com/ansible-community/toolset) docker image. + +## Licensing + +This collection is distributed under the MIT license. + +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. + +# Author information + +Manala [**(http://www.manala.io/)**](http://www.manala.io) diff --git a/README_COLLECTION.md b/README_COLLECTION.md deleted file mode 100644 index 77843412e..000000000 --- a/README_COLLECTION.md +++ /dev/null @@ -1,171 +0,0 @@ -# Ansible Collection - -## Details - - [accounts](https://github.com/manala/ansible-role-accounts) Ansible role dealing with the setup of users and groups accounts and ssh keys. [![Build Status](https://travis-ci.org/manala/ansible-role-accounts.svg?branch=master)](https://travis-ci.org/manala/ansible-role-accounts) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-accounts.svg)](https://img.shields.io/github/release/manala/ansible-role-accounts.svg) - - [alternatives](https://github.com/manala/ansible-role-alternatives) This role will deal with the setup of __alternatives__. [![Build Status](https://travis-ci.org/manala/ansible-role-alternatives.svg?branch=master)](https://travis-ci.org/manala/ansible-role-alternatives) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-alternatives.svg)](https://img.shields.io/github/release/manala/ansible-role-alternatives.svg) - - [ansible](https://github.com/manala/ansible-role-ansible) This role will deal with the setup and the config of [Ansible](https://www.ansible.com/). [![Build Status](https://travis-ci.org/manala/ansible-role-ansible.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ansible) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-ansible.svg)](https://img.shields.io/github/release/manala/ansible-role-ansible.svg) - - [ansible_galaxy](https://github.com/manala/ansible-role-ansible_galaxy) This role will deal with the setup of __Ansible Galaxy__. [![Build Status](https://travis-ci.org/manala/ansible-role-ansible_galaxy.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ansible_galaxy) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-ansible_galaxy.svg)](https://img.shields.io/github/release/manala/ansible-role-ansible_galaxy.svg) - - [apparmor](https://github.com/manala/ansible-role-apparmor) This role will deal with the setup of AppArmor. [![Build Status](https://travis-ci.org/manala/ansible-role-apparmor.svg?branch=master)](https://travis-ci.org/manala/ansible-role-apparmor) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-apparmor.svg)](https://img.shields.io/github/release/manala/ansible-role-apparmor.svg) - - [apt](https://github.com/manala/ansible-role-apt) This role will add third party sources to the package manager. [![Build Status](https://travis-ci.org/manala/ansible-role-apt.svg?branch=master)](https://travis-ci.org/manala/ansible-role-apt) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-apt.svg)](https://img.shields.io/github/release/manala/ansible-role-apt.svg) - - [aptly](https://github.com/manala/ansible-role-aptly) This role will deal with the setup of [Aptly](https://www.aptly.info/). [![Build Status](https://travis-ci.org/manala/ansible-role-aptly.svg?branch=master)](https://travis-ci.org/manala/ansible-role-aptly) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-aptly.svg)](https://img.shields.io/github/release/manala/ansible-role-aptly.svg) - - [backup_manager](https://github.com/manala/ansible-role-backup_manager) This role will deal with the setup of [Backup Manager](https://github.com/sukria/Backup-Manager). [![Build Status](https://travis-ci.org/manala/ansible-role-backup_manager.svg?branch=master)](https://travis-ci.org/manala/ansible-role-backup_manager) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-backup_manager.svg)](https://img.shields.io/github/release/manala/ansible-role-backup_manager.svg) - - [beanstalkd](https://github.com/manala/ansible-role-beanstalkd) This role will deal with the setup of [Beanstalkd](http://kr.github.io/beanstalkd/). [![Build Status](https://travis-ci.org/manala/ansible-role-beanstalkd.svg?branch=master)](https://travis-ci.org/manala/ansible-role-beanstalkd) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-beanstalkd.svg)](https://img.shields.io/github/release/manala/ansible-role-beanstalkd.svg) - - [bind](https://github.com/manala/ansible-role-bind) This role will deal with the setup of [Bind](https://www.isc.org/downloads/bind/). [![Build Status](https://travis-ci.org/manala/ansible-role-bind.svg?branch=master)](https://travis-ci.org/manala/ansible-role-bind) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-bind.svg)](https://img.shields.io/github/release/manala/ansible-role-bind.svg) - - [cloud_init](https://github.com/manala/ansible-role-cloud_init) This role will deal with the configuration of [Cloud-init](https://cloud-init.io/). [![Build Status](https://travis-ci.org/manala/ansible-role-cloud_init.svg?branch=master)](https://travis-ci.org/manala/ansible-role-cloud_init) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-cloud_init.svg)](https://img.shields.io/github/release/manala/ansible-role-cloud_init.svg) - - [composer](https://github.com/manala/ansible-role-composer) This role will deal with the setup of [Composer](https://getcomposer.org) [![Build Status](https://travis-ci.org/manala/ansible-role-composer.svg?branch=master)](https://travis-ci.org/manala/ansible-role-composer) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-composer.svg)](https://img.shields.io/github/release/manala/ansible-role-composer.svg) - - [cron](https://github.com/manala/ansible-role-cron) This role will deal with the setup of __Cron__. [![Build Status](https://travis-ci.org/manala/ansible-role-cron.svg?branch=master)](https://travis-ci.org/manala/ansible-role-cron) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-cron.svg)](https://img.shields.io/github/release/manala/ansible-role-cron.svg) - - [deploy](https://github.com/manala/ansible-role-deploy) This role will deal with __Deployment__. [![Build Status](https://travis-ci.org/manala/ansible-role-deploy.svg?branch=master)](https://travis-ci.org/manala/ansible-role-deploy) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-deploy.svg)](https://img.shields.io/github/release/manala/ansible-role-deploy.svg) - - [dhcp](https://github.com/manala/ansible-role-dhcp) This role will deal with the setup of [ISC DHCP Server](https://www.isc.org/downloads/dhcp/). [![Build Status](https://travis-ci.org/manala/ansible-role-dhcp.svg?branch=master)](https://travis-ci.org/manala/ansible-role-dhcp) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-dhcp.svg)](https://img.shields.io/github/release/manala/ansible-role-dhcp.svg) - - [dnsmasq](https://github.com/manala/ansible-role-dnsmasq) This role will deal with the setup of [Dnsmasq](http://www.thekelleys.org.uk/dnsmasq/doc.html). [![Build Status](https://travis-ci.org/manala/ansible-role-dnsmasq.svg?branch=master)](https://travis-ci.org/manala/ansible-role-dnsmasq) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-dnsmasq.svg)](https://img.shields.io/github/release/manala/ansible-role-dnsmasq.svg) - - [docker](https://github.com/manala/ansible-role-docker) This role will deal with the setup of [Docker](https://www.docker.com/). [![Build Status](https://travis-ci.org/manala/ansible-role-docker.svg?branch=master)](https://travis-ci.org/manala/ansible-role-docker) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-docker.svg)](https://img.shields.io/github/release/manala/ansible-role-docker.svg) - - [elasticsearch](https://github.com/manala/ansible-role-elasticsearch) This role will deal with the setup of [Elasticsearch](https://www.elastic.co/fr/products/elasticsearch). [![Build Status](https://travis-ci.org/manala/ansible-role-elasticsearch.svg?branch=master)](https://travis-ci.org/manala/ansible-role-elasticsearch) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-elasticsearch.svg)](https://img.shields.io/github/release/manala/ansible-role-elasticsearch.svg) - - [environment](https://github.com/manala/ansible-role-environment) This role will deal with the setup of environment variables. [![Build Status](https://travis-ci.org/manala/ansible-role-environment.svg?branch=master)](https://travis-ci.org/manala/ansible-role-environment) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-environment.svg)](https://img.shields.io/github/release/manala/ansible-role-environment.svg) - - [fail2ban](https://github.com/manala/ansible-role-fail2ban) This role will deal with the setup and config of [Fail2Ban](https://www.fail2ban.org/wiki/index.php/Main_Page). [![Build Status](https://travis-ci.org/manala/ansible-role-fail2ban.svg?branch=master)](https://travis-ci.org/manala/ansible-role-fail2ban) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-fail2ban.svg)](https://img.shields.io/github/release/manala/ansible-role-fail2ban.svg) - - [files](https://github.com/manala/ansible-role-files) This role will deal with the attributes of files. [![Build Status](https://travis-ci.org/manala/ansible-role-files.svg?branch=master)](https://travis-ci.org/manala/ansible-role-files) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-files.svg)](https://img.shields.io/github/release/manala/ansible-role-files.svg) - - [git](https://github.com/manala/ansible-role-git) This role will deal with the setup and configuration of git. [![Build Status](https://travis-ci.org/manala/ansible-role-git.svg?branch=master)](https://travis-ci.org/manala/ansible-role-git) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-git.svg)](https://img.shields.io/github/release/manala/ansible-role-git.svg) - - [gitlab](https://github.com/manala/ansible-role-gitlab) This role will assume the setup of [Gitlab](https://about.gitlab.com/). [![Build Status](https://travis-ci.org/manala/ansible-role-gitlab.svg?branch=master)](https://travis-ci.org/manala/ansible-role-gitlab) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-gitlab.svg)](https://img.shields.io/github/release/manala/ansible-role-gitlab.svg) - - [gomplate](https://github.com/manala/ansible-roles/tree/master/roles/gomplate) This role will deal with the setup of [Gomplate](https://github.com/hairyhenderson/gomplate/releases) - - [glusterfs](https://github.com/manala/ansible-role-glusterfs) This role will assume the setup of [GlusterFS](https://www.gluster.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-glusterfs.svg?branch=master)](https://travis-ci.org/manala/ansible-role-glusterfs) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-glusterfs.svg)](https://img.shields.io/github/release/manala/ansible-role-glusterfs.svg) - - [grafana](https://github.com/manala/ansible-role-grafana) This role will deal with the configuration of [Grafana](http://grafana.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-grafana.svg?branch=master)](https://travis-ci.org/manala/ansible-role-grafana) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-grafana.svg)](https://img.shields.io/github/release/manala/ansible-role-grafana.svg) - - [graylog_sidecar](https://github.com/manala/ansible-role-graylog_sidecar) This role will deal with the configuration of [Graylog_sidecar](https://github.com/Graylog2/collector-sidecar). [![Build Status](https://travis-ci.org/manala/ansible-role-graylog_sidecar.svg?branch=master)](https://travis-ci.org/manala/ansible-role-graylog_sidecar) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-graylog_sidecar.svg)](https://img.shields.io/github/release/manala/ansible-role-graylog_sidecar.svg) - - [haproxy](https://github.com/manala/ansible-role-haproxy) This role will deal with the setup of [HAProxy](http://www.haproxy.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-haproxy.svg?branch=master)](https://travis-ci.org/manala/ansible-role-haproxy) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-haproxy.svg)](https://img.shields.io/github/release/manala/ansible-role-haproxy.svg) - - [hugo](https://github.com/manala/ansible-role-hugo) This role will deal with the setup of [Hugo](https://gohugo.io/). [![Build Status](https://travis-ci.org/manala/ansible-role-hugo.svg?branch=master)](https://travis-ci.org/manala/ansible-role-hugo) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-hugo.svg)](https://img.shields.io/github/release/manala/ansible-role-hugo.svg) - - [influxdb](https://github.com/manala/ansible-role-influxdb) This role will assume the setup of [InfluxDB](https://www.influxdata.com/time-series-platform/influxdb/). [![Build Status](https://travis-ci.org/manala/ansible-role-influxdb.svg?branch=master)](https://travis-ci.org/manala/ansible-role-influxdb) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-influxdb.svg)](https://img.shields.io/github/release/manala/ansible-role-influxdb.svg) - - [java](https://github.com/manala/ansible-role-java) This role will deal with the setup of __java__. [![Build Status](https://travis-ci.org/manala/ansible-role-java.svg?branch=master)](https://travis-ci.org/manala/ansible-role-java) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-java.svg)](https://img.shields.io/github/release/manala/ansible-role-java.svg) - - [keepalived](https://github.com/manala/ansible-role-keepalived) This role will deal with the setup and the configuration of [Keepalived](http://www.keepalived.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-keepalived.svg?branch=master)](https://travis-ci.org/manala/ansible-role-keepalived) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-keepalived.svg)](https://img.shields.io/github/release/manala/ansible-role-keepalived.svg) - - [kernel](https://github.com/manala/ansible-role-kernel) This role will assume the setup of kernel. [![Build Status](https://travis-ci.org/manala/ansible-role-kernel.svg?branch=master)](https://travis-ci.org/manala/ansible-role-kernel) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-kernel.svg)](https://img.shields.io/github/release/manala/ansible-role-kernel.svg) - - [locales](https://github.com/manala/ansible-role-locales) This role will deal with the configuration of system __locales__. [![Build Status](https://travis-ci.org/manala/ansible-role-locales.svg?branch=master)](https://travis-ci.org/manala/ansible-role-locales) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-locales.svg)](https://img.shields.io/github/release/manala/ansible-role-locales.svg) - - [logentries](https://github.com/manala/ansible-role-logentries) This role will deal with the configuration of [Logentries](https://logentries.com/). [![Build Status](https://travis-ci.org/manala/ansible-role-logentries.svg?branch=master)](https://travis-ci.org/manala/ansible-role-logentries) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-logentries.svg)](https://img.shields.io/github/release/manala/ansible-role-logentries.svg) - - [logrotate](https://github.com/manala/ansible-role-logrotate) This role will assume the setup of Logrotate. [![Build Status](https://travis-ci.org/manala/ansible-role-logrotate.svg?branch=master)](https://travis-ci.org/manala/ansible-role-logrotate) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-logrotate.svg)](https://img.shields.io/github/release/manala/ansible-role-logrotate.svg) - - [mailhog](https://github.com/manala/ansible-role-mailhog) This role will deal with the setup and the config of [Mailhog](https://github.com/mailhog/MailHog). [![Build Status](https://travis-ci.org/manala/ansible-role-mailhog.svg?branch=master)](https://travis-ci.org/manala/ansible-role-mailhog) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-mailhog.svg)](https://img.shields.io/github/release/manala/ansible-role-mailhog.svg) - - [make](https://github.com/manala/ansible-role-make) This role will deal with the setup of __make__. [![Build Status](https://travis-ci.org/manala/ansible-role-make.svg?branch=master)](https://travis-ci.org/manala/ansible-role-make) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-make.svg)](https://img.shields.io/github/release/manala/ansible-role-make.svg) - - [maxscale](https://github.com/manala/ansible-role-maxscale) This role will deal with the setup and configuration of [Maxscale](https://mariadb.com/products/technology/maxscale). [![Build Status](https://travis-ci.org/manala/ansible-role-maxscale.svg?branch=master)](https://travis-ci.org/manala/ansible-role-maxscale) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-maxscale.svg)](https://img.shields.io/github/release/manala/ansible-role-maxscale.svg) - - [merge](https://github.com/manala/ansible-role-merge) This role will deal with the merging of ansible variables. [![Build Status](https://travis-ci.org/manala/ansible-role-merge.svg?branch=master)](https://travis-ci.org/manala/ansible-role-merge) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-merge.svg)](https://img.shields.io/github/release/manala/ansible-role-merge.svg) - - [mongo_express](https://github.com/manala/ansible-role-mongo_express) This role will deal with the setup and install of [Mongo Express](https://github.com/mongo-express/mongo-express). [![Build Status](https://travis-ci.org/manala/ansible-role-mongo_express.svg?branch=master)](https://travis-ci.org/manala/ansible-role-mongo_express) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-mongo_express.svg)](https://img.shields.io/github/release/manala/ansible-role-mongo_express.svg) - - [mongodb](https://github.com/manala/ansible-role-mongodb) This role will deal with the setup of [Mongodb](https://www.mongodb.com/fr). [![Build Status](https://travis-ci.org/manala/ansible-role-mongodb.svg?branch=master)](https://travis-ci.org/manala/ansible-role-mongodb) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-mongodb.svg)](https://img.shields.io/github/release/manala/ansible-role-mongodb.svg) - - [motd](https://github.com/manala/ansible-role-motd) This role will deal with the setup of Message Of The Day. [![Build Status](https://travis-ci.org/manala/ansible-role-motd.svg?branch=master)](https://travis-ci.org/manala/ansible-role-motd) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-motd.svg)](https://img.shields.io/github/release/manala/ansible-role-motd.svg) - - [mount](https://github.com/manala/ansible-role-mount) This role will deal with the setup of mount points. [![Build Status](https://travis-ci.org/manala/ansible-role-mount.svg?branch=master)](https://travis-ci.org/manala/ansible-role-mount) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-mount.svg)](https://img.shields.io/github/release/manala/ansible-role-mount.svg) - - [mysql](https://github.com/manala/ansible-role-mysql) This role will deal with the setup of [Mysql](https://www.mysql.com/). [![Build Status](https://travis-ci.org/manala/ansible-role-mysql.svg?branch=master)](https://travis-ci.org/manala/ansible-role-mysql) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-mysql.svg)](https://img.shields.io/github/release/manala/ansible-role-mysql.svg) - - [network](https://github.com/manala/ansible-role-network) This role will handle network hosts, resolver and interfaces. [![Build Status](https://travis-ci.org/manala/ansible-role-network.svg?branch=master)](https://travis-ci.org/manala/ansible-role-network) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-network.svg)](https://img.shields.io/github/release/manala/ansible-role-network.svg) - - [nginx](https://github.com/manala/ansible-role-nginx) This role will deal with the setup and config of [Nginx](https://nginx.org/en/). [![Build Status](https://travis-ci.org/manala/ansible-role-nginx.svg?branch=master)](https://travis-ci.org/manala/ansible-role-nginx) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-nginx.svg)](https://img.shields.io/github/release/manala/ansible-role-nginx.svg) - - [ngrok](https://github.com/manala/ansible-role-ngrok) This role will deal with the setup and the config of [Ngrok](https://ngrok.com/). [![Build Status](https://travis-ci.org/manala/ansible-role-ngrok.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ngrok) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-ngrok.svg)](https://img.shields.io/github/release/manala/ansible-role-ngrok.svg) - - [nodejs](https://github.com/manala/ansible-role-nodejs) This role will deal with the setup of [Nodejs](https://nodejs.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-nodejs.svg?branch=master)](https://travis-ci.org/manala/ansible-role-nodejs) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-nodejs.svg)](https://img.shields.io/github/release/manala/ansible-role-nodejs.svg) - - [npm](https://github.com/manala/ansible-role-npm) This role will deal with the handling of global npm packages. [![Build Status](https://travis-ci.org/manala/ansible-role-npm.svg?branch=master)](https://travis-ci.org/manala/ansible-role-npm) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-npm.svg)](https://img.shields.io/github/release/manala/ansible-role-npm.svg) - - [ntp](https://github.com/manala/ansible-role-ntp) This role will deal with the setup of [Ntp](http://www.ntp.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-ntp.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ntp) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-ntp.svg)](https://img.shields.io/github/release/manala/ansible-role-ntp.svg) - - [oauth2_proxy](https://github.com/manala/ansible-role-oauth2_proxy) This role will deal with the setup and config of [OAuth2 Proxy](https://github.com/bitly/oauth2_proxy). [![Build Status](https://travis-ci.org/manala/ansible-role-oauth2_proxy.svg?branch=master)](https://travis-ci.org/manala/ansible-role-oauth2_proxy) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-oauth2_proxy.svg)](https://img.shields.io/github/release/manala/ansible-role-oauth2_proxy.svg) - - [ohmyzsh](https://github.com/manala/ansible-role-ohmyzsh) This role will deal with the setup of [Oh My Zsh](http://ohmyz.sh/). [![Build Status](https://travis-ci.org/manala/ansible-role-ohmyzsh.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ohmyzsh) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-ohmyzsh.svg)](https://img.shields.io/github/release/manala/ansible-role-ohmyzsh.svg) - - [opcache_dashboard](https://github.com/manala/ansible-role-opcache_dashboard) This role will deal with the setup and config of [OPcache Dashboard](https://github.com/carlosbuenosvinos/opcache-dashboard). [![Build Status](https://travis-ci.org/manala/ansible-role-opcache_dashboard.svg?branch=master)](https://travis-ci.org/manala/ansible-role-opcache_dashboard) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-opcache_dashboard.svg)](https://img.shields.io/github/release/manala/ansible-role-opcache_dashboard.svg) - - [pam_ssh_agent_auth](https://github.com/manala/ansible-role-pam_ssh_agent_auth) This role will deal with the setup and config of [Pam ssh agent auth](http://pamsshagentauth.sourceforge.net/). [![Build Status](https://travis-ci.org/manala/ansible-role-pam_ssh_agent_auth.svg?branch=master)](https://travis-ci.org/manala/ansible-role-pam_ssh_agent_auth) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-pam_ssh_agent_auth.svg)](https://img.shields.io/github/release/manala/ansible-role-pam_ssh_agent_auth.svg) - - [phantomjs](https://github.com/manala/ansible-role-phantomjs) This role will deal with the setup of [PhantomJS](http://phantomjs.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-phantomjs.svg?branch=master)](https://travis-ci.org/manala/ansible-role-phantomjs) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-phantomjs.svg)](https://img.shields.io/github/release/manala/ansible-role-phantomjs.svg) - - [php](https://github.com/manala/ansible-role-php) This role will deal with the setup and config of PHP. [![Build Status](https://travis-ci.org/manala/ansible-role-php.svg?branch=master)](https://travis-ci.org/manala/ansible-role-php) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-php.svg)](https://img.shields.io/github/release/manala/ansible-role-php.svg) - - [phpmyadmin](https://github.com/manala/ansible-role-phpmyadmin) This role will deal with the setup and config of [PhpMyAdmin](https://www.phpmyadmin.net/). [![Build Status](https://travis-ci.org/manala/ansible-role-phpmyadmin.svg?branch=master)](https://travis-ci.org/manala/ansible-role-phpmyadmin) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-phpmyadmin.svg)](https://img.shields.io/github/release/manala/ansible-role-phpmyadmin.svg) - - [phppgadmin](https://github.com/manala/ansible-role-phppgadmin) This role will deal with the setup and config of [PhpPgAdmin](http://phppgadmin.sourceforge.net/doku.php). [![Build Status](https://travis-ci.org/manala/ansible-role-phppgadmin.svg?branch=master)](https://travis-ci.org/manala/ansible-role-phppgadmin) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-phppgadmin.svg)](https://img.shields.io/github/release/manala/ansible-role-phppgadmin.svg) - - [phpredisadmin](https://github.com/manala/ansible-role-phpredisadmin) This role will deal with the setup and config of [PhpRedisAdmin](https://github.com/erikdubbelboer/phpRedisAdmin). [![Build Status](https://travis-ci.org/manala/ansible-role-phpredisadmin.svg?branch=master)](https://travis-ci.org/manala/ansible-role-phpredisadmin) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-phpredisadmin.svg)](https://img.shields.io/github/release/manala/ansible-role-phpredisadmin.svg) - - [postgresql](https://github.com/manala/ansible-role-postgresql) This role will deal with the setup of [PostgreSQL](http://www.postgresql.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-postgresql.svg?branch=master)](https://travis-ci.org/manala/ansible-role-postgresql) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-postgresql.svg)](https://img.shields.io/github/release/manala/ansible-role-postgresql.svg) - - [proftpd](https://github.com/manala/ansible-role-proftpd) This role will deal with the setup of [ProFTPd](http://www.proftpd.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-proftpd.svg?branch=master)](https://travis-ci.org/manala/ansible-role-proftpd) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-proftpd.svg)](https://img.shields.io/github/release/manala/ansible-role-proftpd.svg) - - [proxmox](https://github.com/manala/ansible-role-proxmox) This role will deal with the setup of [Proxmox](https://www.proxmox.com/en/). [![Build Status](https://travis-ci.org/manala/ansible-role-proxmox.svg?branch=master)](https://travis-ci.org/manala/ansible-role-proxmox) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-proxmox.svg)](https://img.shields.io/github/release/manala/ansible-role-proxmox.svg) - - [redis](https://github.com/manala/ansible-role-redis) This role will deal with the setup of [Redis](https://redis.io/). [![Build Status](https://travis-ci.org/manala/ansible-role-redis.svg?branch=master)](https://travis-ci.org/manala/ansible-role-redis) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-redis.svg)](https://img.shields.io/github/release/manala/ansible-role-redis.svg) - - [rsyslog](https://github.com/manala/ansible-role-rsyslog) This role will deal with the setup of [Rsyslog](http://www.rsyslog.com/). [![Build Status](https://travis-ci.org/manala/ansible-role-rsyslog.svg?branch=master)](https://travis-ci.org/manala/ansible-role-rsyslog) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-rsyslog.svg)](https://img.shields.io/github/release/manala/ansible-role-rsyslog.svg) - - [sensu](https://github.com/manala/ansible-role-sensu) This role will deal with the setup of [Sensu](https://sensuapp.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-sensu.svg?branch=master)](https://travis-ci.org/manala/ansible-role-sensu) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-sensu.svg)](https://img.shields.io/github/release/manala/ansible-role-sensu.svg) - - [sensu_go](https://github.com/manala/ansible-role-sensu_go) This role will deal with the setup of [Sensu Go](https://sensu.io/). [![Build Status](https://travis-ci.org/manala/ansible-role-sensu_go.svg?branch=master)](https://travis-ci.org/manala/ansible-role-sensu_go) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-sensu_go.svg)](https://img.shields.io/github/release/manala/ansible-role-sensu_go.svg) - - [shorewall](https://github.com/manala/ansible-role-shorewall) This role will assume the setup of [Shorewall](http://shorewall.net/). [![Build Status](https://travis-ci.org/manala/ansible-role-shorewall.svg?branch=master)](https://travis-ci.org/manala/ansible-role-shorewall) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-shorewall.svg)](https://img.shields.io/github/release/manala/ansible-role-shorewall.svg) - - [skeleton](https://github.com/manala/ansible-role-skeleton) This role handle skeletons patterns and options. [![Build Status](https://travis-ci.org/manala/ansible-role-skeleton.svg?branch=master)](https://travis-ci.org/manala/ansible-role-skeleton) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-skeleton.svg)](https://img.shields.io/github/release/manala/ansible-role-skeleton.svg) - - [sqlite](https://github.com/manala/ansible-role-sqlite) This role will deal with the setup of [SQLite](https://www.sqlite.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-sqlite.svg?branch=master)](https://travis-ci.org/manala/ansible-role-sqlite) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-sqlite.svg)](https://img.shields.io/github/release/manala/ansible-role-sqlite.svg) - - [ssh](https://github.com/manala/ansible-role-ssh) This role will deal with ssh configurations [![Build Status](https://travis-ci.org/manala/ansible-role-ssh.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ssh) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-ssh.svg)](https://img.shields.io/github/release/manala/ansible-role-ssh.svg) - - [sudo](https://github.com/manala/ansible-role-sudo) This role will deal with the setup of Sudo. [![Build Status](https://travis-ci.org/manala/ansible-role-sudo.svg?branch=master)](https://travis-ci.org/manala/ansible-role-sudo) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-sudo.svg)](https://img.shields.io/github/release/manala/ansible-role-sudo.svg) - - [supervisor](https://github.com/manala/ansible-role-supervisor) This role will deal with the setup of [Supervisor](http://supervisord.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-supervisor.svg?branch=master)](https://travis-ci.org/manala/ansible-role-supervisor) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-supervisor.svg)](https://img.shields.io/github/release/manala/ansible-role-supervisor.svg) - - [symfony_cli](https://github.com/manala/ansible-roles/tree/master/roles/symfony_cli) This role will deal with the setup of [Symfony Cli](https://symfony.com/download). - - [systemd](https://github.com/manala/ansible-role-systemd) This role will deal with the setup of Systemd. [![Build Status](https://travis-ci.org/manala/ansible-role-systemd.svg?branch=master)](https://travis-ci.org/manala/ansible-role-systemd) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-systemd.svg)](https://img.shields.io/github/release/manala/ansible-role-systemd.svg) - - [telegraf](https://github.com/manala/ansible-role-telegraf) This role will deal with the setup and the config of [influxdata Telegraf](https://github.com/influxdata/telegraf). [![Build Status](https://travis-ci.org/manala/ansible-role-telegraf.svg?branch=master)](https://travis-ci.org/manala/ansible-role-telegraf) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-telegraf.svg)](https://img.shields.io/github/release/manala/ansible-role-telegraf.svg) - - [thumbor](https://github.com/manala/ansible-role-thumbor) This role will deal with the setup and the config of [Thumbor](http://thumbor.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-thumbor.svg?branch=master)](https://travis-ci.org/manala/ansible-role-thumbor) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-thumbor.svg)](https://img.shields.io/github/release/manala/ansible-role-thumbor.svg) - - [timezone](https://github.com/manala/ansible-role-timezone) This role will deal with the setup of Timezone. [![Build Status](https://travis-ci.org/manala/ansible-role-timezone.svg?branch=master)](https://travis-ci.org/manala/ansible-role-timezone) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-timezone.svg)](https://img.shields.io/github/release/manala/ansible-role-timezone.svg) - - [varnish](https://github.com/manala/ansible-role-varnish) This role will deal with the setup of [Varnish](https://varnish-cache.org/). [![Build Status](https://travis-ci.org/manala/ansible-role-varnish.svg?branch=master)](https://travis-ci.org/manala/ansible-role-varnish) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-varnish.svg)](https://img.shields.io/github/release/manala/ansible-role-varnish.svg) - - [vault](https://github.com/manala/ansible-role-vault) This role will deal with the setup and configuration of [Hashicorp Vault server](https://www.vaultproject.io/). [![Build Status](https://travis-ci.org/manala/ansible-role-vault.svg?branch=master)](https://travis-ci.org/manala/ansible-role-vault) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-vault.svg)](https://img.shields.io/github/release/manala/ansible-role-vault.svg) - - [vault_cli](https://github.com/manala/ansible-roles/tree/master/roles/vault_cli) This role will deal with the setup of [vault](https://www.vaultproject.io/downloads) - - [vim](https://github.com/manala/ansible-role-vim) This role will deal with the setup and configuration of Vim. [![Build Status](https://travis-ci.org/manala/ansible-role-vim.svg?branch=master)](https://travis-ci.org/manala/ansible-role-vim) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-vim.svg)](https://img.shields.io/github/release/manala/ansible-role-vim.svg) - - [yarn](https://github.com/manala/ansible-role-yarn) This role will deal with the setup of [Yarn](https://yarnpkg.com/). [![Build Status](https://travis-ci.org/manala/ansible-role-yarn.svg?branch=master)](https://travis-ci.org/manala/ansible-role-yarn) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-yarn.svg)](https://img.shields.io/github/release/manala/ansible-role-yarn.svg) - - [zsh](https://github.com/manala/ansible-role-zsh) This role will deal with the setup of Zsh. [![Build Status](https://travis-ci.org/manala/ansible-role-zsh.svg?branch=master)](https://travis-ci.org/manala/ansible-role-zsh) [![Latest Stable Version](https://img.shields.io/github/release/manala/ansible-role-zsh.svg)](https://img.shields.io/github/release/manala/ansible-role-zsh.svg) diff --git a/galaxy.yml b/galaxy.yml index 0a9ca5440..58764b689 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,5 +1,4 @@ ### REQUIRED - # The namespace of the collection. This can be a company/brand/organization or product namespace under which all # content lives. May only contain alphanumeric lowercase characters and underscores. Namespaces cannot start with # underscores or numbers and cannot contain consecutive underscores @@ -17,21 +16,16 @@ readme: README.md # A list of the collection's content authors. Can be just the name or in the format 'Full Name (url) # @nicks:irc/im.site#channel' authors: -- Manala + - Manala ### OPTIONAL but strongly recommended - # A short summary description of the collection description: The flexible, robust, and web oriented toolbox for Ansible # Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only # accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file' license: -- MIT - -# The path to the license file for the collection. This path is relative to the root of the collection. This key is -# mutually exclusive with 'license' -license_file: '' + - MIT # A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character # requirements as 'namespace' and 'name' @@ -50,7 +44,23 @@ repository: https://github.com/manala/ansible-roles documentation: https://github.com/manala/ansible-roles # The URL to the homepage of the collection/project -homepage: http://www.manala.io/ +homepage: https://www.manala.io/ # The URL to the collection issue tracker issues: https://github.com/manala/ansible-roles/issues + +# A list of file glob-like patterns used to filter any files or directories that should not be included in the build +# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This +# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry', +# and '.git' are always filtered +build_ignore: + - .config + - .github + - .env + - .env.dist + - .gitignore + - .DS_Store + - .ansible-lint + - Makefile + - molecule + - tests diff --git a/meta/runtime.yml b/meta/runtime.yml new file mode 100644 index 000000000..bd0ffa497 --- /dev/null +++ b/meta/runtime.yml @@ -0,0 +1,3 @@ +--- + +requires_ansible: '>=2.9' diff --git a/molecule/Dockerfile.debian.bullseye.j2 b/molecule/Dockerfile.debian.bullseye.j2 new file mode 100644 index 000000000..4b87efb55 --- /dev/null +++ b/molecule/Dockerfile.debian.bullseye.j2 @@ -0,0 +1,19 @@ +FROM {{ item.image }} + +# Versions +ENV GOSS_VERSION=0.3.16 + +# System +RUN \ + apt-get update \ + && apt-get install --yes --no-install-recommends \ + curl ca-certificates \ + python3 \ + gnupg \ + procps iproute2 \ + # Bash + && sed -i -e '/PS1=/s/\\h/\\H/' /etc/bash.bashrc \ + # Goss + && curl -sSL https://github.com/aelsabbahy/goss/releases/download/v${GOSS_VERSION}/goss-linux-amd64 \ + -o /usr/local/bin/goss \ + && chmod +x /usr/local/bin/goss diff --git a/molecule/Dockerfile.debian.buster.j2 b/molecule/Dockerfile.debian.buster.j2 new file mode 100644 index 000000000..dbb4bf6a3 --- /dev/null +++ b/molecule/Dockerfile.debian.buster.j2 @@ -0,0 +1,19 @@ +FROM {{ item.image }} + +# Versions +ENV GOSS_VERSION=0.3.16 + +# System +RUN \ + apt-get update \ + && apt-get install --yes --no-install-recommends \ + curl ca-certificates \ + python3 \ + gnupg \ + procps \ + # Bash + && sed -i -e '/PS1=/s/\\h/\\H/' /etc/bash.bashrc \ + # Goss + && curl -sSL https://github.com/aelsabbahy/goss/releases/download/v${GOSS_VERSION}/goss-linux-amd64 \ + -o /usr/local/bin/goss \ + && chmod +x /usr/local/bin/goss diff --git a/molecule/Dockerfile.debian.stretch.j2 b/molecule/Dockerfile.debian.stretch.j2 new file mode 100644 index 000000000..c581c33e7 --- /dev/null +++ b/molecule/Dockerfile.debian.stretch.j2 @@ -0,0 +1,19 @@ +FROM {{ item.image }} + +# Versions +ENV GOSS_VERSION=0.3.16 + +# System +RUN \ + apt-get update \ + && apt-get install --yes --no-install-recommends \ + curl ca-certificates \ + python3 \ + gnupg dirmngr \ + apt-transport-https \ + # Bash + && sed -i -e '/PS1=/s/\\h/\\H/' /etc/bash.bashrc \ + # Goss + && curl -sSL https://github.com/aelsabbahy/goss/releases/download/v${GOSS_VERSION}/goss-linux-amd64 \ + -o /usr/local/bin/goss \ + && chmod +x /usr/local/bin/goss diff --git a/molecule/accounts/converge.yml b/molecule/accounts/converge.yml new file mode 100644 index 000000000..619055266 --- /dev/null +++ b/molecule/accounts/converge.yml @@ -0,0 +1,289 @@ +--- + +########## +# Groups # +########## + +- name: Groups + tags: [groups] + hosts: debian + tasks: + - name: Groups + group: + name: "{{ item }}" + loop: [group_state_absent_existing, group_state_ignore_existing] + - block: + - name: Role + import_role: + name: manala.roles.accounts + tasks_from: groups + vars: + manala_accounts_groups: + # Short syntax + - group_short_syntax + # Simple + - group: group_simple + # verbose syntax + - group: group_verbose_syntax + gid: 1337 + # Flatten + - + - group: group_flatten + # State + - group: group_state_present_implicit + - group: group_state_present + state: present + - group: group_state_absent + state: absent + - group: group_state_absent_existing + state: absent + - group: group_state_ignore + state: ignore + - group: group_state_ignore_existing + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/groups.yml.j2') }}" + +######### +# Users # +######### + +- name: Users + tags: [users] + hosts: debian + tasks: + - name: Groups + group: + name: "{{ item }}" + loop: [users_group] + - name: Users + user: + name: "{{ item }}" + loop: [user_state_absent_existing, user_state_ignore_existing] + - block: + - name: Role + import_role: + name: manala.roles.accounts + tasks_from: users + vars: + manala_accounts_users: + # Short syntax + - user_short_syntax + # Simple + - user: user_simple + # Verbose syntax + - user: user_verbose_syntax + group: users_group + # Flatten + - + - user: user_flatten + # State + - user: user_state_present_implicit + - user: user_state_present + state: present + - user: user_state_absent + state: absent + - user: user_state_absent_existing + state: absent + - user: user_state_ignore + state: ignore + - user: user_state_ignore_existing + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/users.yml.j2') }}" + +######################### +# Users Authorized Keys # +######################### + +- name: Users Authorized Keys + tags: [users_authorized_keys] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.accounts + tasks_from: users + vars: + manala_accounts_users: + # Short syntax + - user_ak_short_syntax + # Simple + - user: user_ak_simple + # Verbose syntax + - user: user_ak_verbose_syntax + authorized_keys: + - "{{ lookup('file', 'fixtures/key_1.pub') }}" + # Flatten + - + - user: user_ak_flatten + authorized_keys: + - "{{ lookup('file', 'fixtures/key_1.pub') }}" + # Multiple + - user: user_ak_multiple + authorized_keys: + - "{{ lookup('file', 'fixtures/key_1.pub') }}" + - "{{ lookup('file', 'fixtures/key_2.pub') }}" + # File + - user: user_ak_file + authorized_keys_file: authorized_keys2 + authorized_keys: + - "{{ lookup('file', 'fixtures/key_1.pub') }}" + # State + - user: user_ak_state_ignore + authorized_keys: + - "{{ lookup('file', 'fixtures/key_1.pub') }}" + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/users_authorized_keys.yml.j2') }}" + +############## +# Users Keys # +############## + +- name: Users Keys + tags: [users_keys] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.accounts + tasks_from: users + vars: + manala_accounts_users: + # Short syntax + - user_k_short_syntax + # Simple + - user: user_k_simple + # None + - user: user_k_none + keys: + - key: id_rsa + # Private + - user: user_k_private + keys: + - key: id_rsa + private: "{{ lookup('file', 'fixtures/key_1') }}" + # Public + - user: user_k_public + keys: + - key: id_rsa + public: "{{ lookup('file', 'fixtures/key_1.pub') }}" + # Verbose syntax + - user: user_k_verbose_syntax + keys: + - key: id_rsa + private: "{{ lookup('file', 'fixtures/key_1') }}" + public: "{{ lookup('file', 'fixtures/key_1.pub') }}" + # Flatten + - + - user: user_k_flatten + keys: + - private: "{{ lookup('file', 'fixtures/key_1') }}" + public: "{{ lookup('file', 'fixtures/key_1.pub') }}" + # Multiple + - user: user_k_multiple + keys: + - key: id_rsa_1 + private: "{{ lookup('file', 'fixtures/key_1') }}" + public: "{{ lookup('file', 'fixtures/key_1.pub') }}" + - key: id_rsa_2 + private: "{{ lookup('file', 'fixtures/key_2') }}" + public: "{{ lookup('file', 'fixtures/key_2.pub') }}" + # State + - user: user_k_state_ignore + keys: + - private: "{{ lookup('file', 'fixtures/key_1') }}" + public: "{{ lookup('file', 'fixtures/key_1.pub') }}" + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/users_keys.yml.j2') }}" + +################## +# Users Gpg Keys # +################## + +- name: Users Gpg Keys + tags: [users_gpg_keys] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.accounts + tasks_from: users + vars: + manala_accounts_users: + # Short syntax + - user_gk_short_syntax + # Simple + - user: user_gk_simple + # None + - user: user_gk_none + gpg_keys: + - key: EEFB7858B3971AA2 + # Public + - user: user_gk_public + gpg_keys: + - key: EEFB7858B3971AA2 + public: "{{ lookup('file', 'fixtures/gpg_key_1.pub') }}" + # Secret + - user: user_gk_secret + gpg_keys: + - key: EEFB7858B3971AA2 + secret: "{{ lookup('file', 'fixtures/gpg_key_1') }}" + # Trust + - user: user_gk_trust + gpg_keys: + - key: EEFB7858B3971AA2 + public: "{{ lookup('file', 'fixtures/gpg_key_1.pub') }}" + trust: true + # Verbose syntax + - user: user_gk_verbose_syntax + gpg_keys: + - key: EEFB7858B3971AA2 + public: "{{ lookup('file', 'fixtures/gpg_key_1.pub') }}" + secret: "{{ lookup('file', 'fixtures/gpg_key_1') }}" + # Flatten + - + - user: user_gk_flatten + gpg_keys: + - key: EEFB7858B3971AA2 + public: "{{ lookup('file', 'fixtures/gpg_key_1.pub') }}" + secret: "{{ lookup('file', 'fixtures/gpg_key_1') }}" + # Multiple + - user: user_gk_multiple + keys: + gpg_keys: + - key: EEFB7858B3971AA2 + public: "{{ lookup('file', 'fixtures/gpg_key_1.pub') }}" + secret: "{{ lookup('file', 'fixtures/gpg_key_1') }}" + - key: 3C0AA0CD6E3382DA + public: "{{ lookup('file', 'fixtures/gpg_key_2.pub') }}" + secret: "{{ lookup('file', 'fixtures/gpg_key_2') }}" + # State + - user: user_gk_state_ignore + gpg_keys: + - key: EEFB7858B3971AA2 + public: "{{ lookup('file', 'fixtures/gpg_key_1.pub') }}" + secret: "{{ lookup('file', 'fixtures/gpg_key_1') }}" + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/users_gpg_keys.yml.j2') }}" diff --git a/molecule/accounts/fixtures/gpg_key_1 b/molecule/accounts/fixtures/gpg_key_1 new file mode 100644 index 000000000..13c8b5181 --- /dev/null +++ b/molecule/accounts/fixtures/gpg_key_1 @@ -0,0 +1,81 @@ +-----BEGIN PGP PRIVATE KEY BLOCK----- + +lQVYBGF3sHIBDADlStPx5qQ18/rYBGmkBZSGAbxIo4D+eWM3Zg0q2xGZWGQ+eqph +LrDIRlxOR1fq1QPkCid/p79cGNPa4kLSh8rUiUoFY21tUjaIgSsLRtGyiiSlCc4b +I0/lbqenfSca0OsXKku/EaKMuuvgpGgqXypuY0zO3UVpPF0pW+gTWGwLd9VHPSvJ +X0czP/WITF8SYfj31sFjAy2mIsksiANclpq0OHqZwjU4IrxQC4HifeXvkQb+IxB7 +S8wUSwvm+Mg9f9wnB4s7/RN+1TdZqRxzzf7owGIbSMZX9DKQUy+gS0XSz+IwDdCi +Q6U28MFcpq2TRYj6d9QIwhm2ib/IzvKSq6otm1v/u0XlzJaNZL7m5b/0Mc6Il8Uw +M6nsNBUL9rc+wtP8DeheP+6ycfZGIyuym2RNlpa0317a6h4a9Q4Yi8EQluXHPbuU +HR8bp8GYm1iBLGFB9IOlbCES2fsZYNmHf3/Zk7MRound+o/hpDns1qd4CGT50Rrb +J22XF5WJqJoTsvkAEQEAAQAL/RdAqgL6dO1wRUBeHTD4LGZVG3kh1Klp2bsS3zO5 +BN1AUqUn5yqlE6IxyXdaQpMS4FrCQVxvoGc4cNaeErD7OqFoXVBz03NuTo+0Cq+R +cl9Y5Uuz1XoY0AfIO5oPhfVRGcAvBsC1Cv8azyQoRBSE815/tTi2xYzdJWT1+DBr +C4TztXYsoMnCfuvWeQHGHe+VLiyDE7hE6J6UIULh9bZQYxay8hLw+Bjt49s5uYWk +pxpvAo6n82pPht4JeMbm9JaRBksg5O6PelrLWiw2TZv5LQPVHc0sMgKv6pCbhWF5 +LXAqwUt8lRmKynvgZWUeKEJ8Mzuz1BuudExbsH85Q1YABrTO9AI8Zv4mgdqHnEb8 +No1y1jVe5pL1e3tcqDw8Y4BlLJoR6xQgAF2QkZY0gnyhZCPCUyVTAfcjAME4xAo5 +8OQtg8+lCpoYIA925n+G/fHB5CpW/mPkoMmpH2zbC6PCR7r1wNcqfIhm3J7/AdrR +QhDA9zF7mzPXhp/tKiBhM1rJ8QYA5zKlIo/H79+irpbXfa+j2soHoE0fvJ7Yi+7m +VjhvIrO8DFn3dJOwbU0FWyP9OJKPKruNXv/XJGyN1Pt/Kr+n0Swzvwb+iBKBMIiL +FYj5W3sQ+lfc/n4/4YRCoiJcZwRyrv+m7GuATQ0oEAKV5FdAhYmHxAnaMe1R2ncl +oeJyDUNRqiUzVpCpy2qb3sYqkdqCs4yzWGF4QuviT8KgvPY1/hoG6zokdzGtZ3mU +s5HrNQUtGp9b/VDhhbwu3Dydb+PxBgD949n0B10QdzFMFJUjFAJRGaLetUA4EF6Q +9l5tO+1RnvlvHMZVTZ3zUQ2fJDKYTTrdGCBWLjWdz0vyPw9hzYEM8xc9TbWKvt/B ++5QYrhyAXVoPCFxBokq/GlxhvtVA+sXOXLUpqXbJKOJE5T6bxJ91i5xAHTH0dhU7 +OnnQZ+PG92xMZwdRZq9KTIIVAcBfj1kg1nqHbPY2yvgjlZp8pRvqH2Wsb9dcPojI +RJV3eMnM9hNmxft/OPplk534I+oJJ4kGAMlEmkTXM6BLeHQbxRFMRNDDiMC6xwDp +bIfCus8evDBQ60CCUy4oXb73mVLRpXMBUwUPcDZ3SBxd5VAtVHhzAexhJaDL9ojL +k9wn9ZzRjlfUKhMrqR0JDbsQVWvJJ4BM8pmqCrwLuuxFPOHKx59y9/wZzFMCB+KW +fJPZypv36VXEdtLBQAEqpa65ewMe9I/LbiwrSgxRWWXxWcFzn4krb6rVbA83/wED +qxAyFPhdEhvTC9c0pkZJD78xH250yT8nxtNBtCNtYW5hbGEgKE1hbmFsYSkgPGNv +bnRhY3RAbWFuYWxhLmlvPokBzgQTAQoAOBYhBAuHeaXlguOUn5s8Lu77eFizlxqi +BQJhd7ByAhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEO77eFizlxqiTWcM +AMejBMkcW80QQ6aJlm2RD+wr1CRejpvLOC+PkJDowXDMEQGGoXzwaWBG9ZcbsOW0 +8XU0rFnwbKJMUwcY9TLjiuIzZU6sQKMK9lQWeWZ8b6hJG9YFbaQn+T8/TF5A17hJ +XvwuggoD/abJoA4+oCh+axJqGeGrbp5KqBw2PMIZ0CvGd7dmwA0pudoBy/g0uMLk +IG14K86iH//M5OBJ22omgw3Q7acxd2c83RaKu/ilJ4TR8sFN4U3lV6E4t7DHToIp +IP8cMRElxgbRmNUiD+1CIw6kdtk6c1i8ZbO1R0HhmDQvvxeM9airhjRSK4TARZVe +Krc07X1C2cstScaIjAfgsTA2zgegZSYV1xrSJQIlHO1b1Bv4Ss/jY/WtgKCpt0hx +cgouqjYznk02nuocAMPtZQevfz9Fr4JH8jS2whUnX8vcng5U4Prt2rEFTNnQK2UT +OP8+4JJ2thTZCyxZn6KpZeD829438yngmyhOfWpIpavFNppaHU33UEn0ptaik1+3 +450FWARhd7ByAQwApZxOlVESnu549/mo+7nhwzXRsHPK+vIxFIArxcQJ43+vn4uf +hLKv+VXWA9eMhm7TyrqN5jzx0Un7VC5fZ1+Xh0AYGLzgYLakzwnsi4FQZLIDmos7 +vb3Rdk4gmeKKH7oj0aVWgPUMin3tyQSx2hZP+GM3T7dGUWsWM6Auo2P6Zx0euzDX +qCJt5dADdmOS2gEZM8f+OnfsKfuj5gLb5LBU00t5G+ixg9j3l+8yc8UqT9riF+Vn +tVseCqefFnjdL052w2xF7S9WL0+AcBz8VwUkRXVH6F1VEjralQp8PH7P+BxoMfXc +JBRl0+UunW5I5lX3nZbq2R6FS2Wy0FI+qW+Bg2BOLtGWj0YoL4bm1cKOrx1/GLcg +u4HP2Tz5e+f7pz0a4V4u0imQ2lzRxyMEVjEWnCcQ02RnGplOPJmSU3gmxwxittxk +ESyJiyx4q6G5fpcrSJUQ07HJ6IwXnlcOGRyIjBt2ZICTjIt8c7tJu8/+F7KK/MX7 +SigCdI6P6YXp3xHvABEBAAEAC/wL5wmA0smsptqxMSjTerRpSXIaJUsBMSyU2sdf +7dXWG28IX5+7M5/RIuRVn1rIA1QbyGpQEgZBMqN/v9t3JwLReNT324Shfs772wHn +Xt0Od6V+/c3Gi8tvnhraudI6iIVwLlq4EaSb7tlgWVgyTT3keLZYzNp0GecHwStI +7p5oZcqNIpav91WAWaxoswGywwxy0Ry09WSBpJvOzrAg0LQwAXHMBIkplDZAnbOP +EtcWfoFBvWjwOwMUOfWFnHHX0g2P0fBYD09IyQgQvBjNaAxIk4gRjLf+E+4sxwbl +Adn+JVsq1iSRvIsXvWLEserE4837AcQXmSXng1ufuLWX5TsrrRBygsYWSGpCRe1G +Ueluy/GaB8fSaJFqe8F6hiXJEi/XB2/XJYHiGoDUXFaZdzwfkv8QnxFb9ii05JSs +popuCDGIfvDMLpBwpQgaiJxuAoeCJIzpRtDNOMA47uEheDSABTpoVAwY0iI8AgUR +csqQ9EsdlRaPEvarN9tqO0RX3NEGAMxSuD2HGYxqC0yqRe/IBEiOvIv7JbupiMFU +fmqzQApc+SdPQlw5s8Rhsih262HJWQvX3jCk0uJXn/xP9HUwMbNya+iJN/mrbTJN +s4SdfCHq3bL6Dt9n8QYPQivHHGJKLgZAX2cZHVSRIQ/kjAE1P8C4L0vZPh0tCH1p +q/QqVztw8mwYOqXxrENbEQ53rul4mXdjr/sO1yAoMlYRQRdahQAlCPpQUlqFm/nB +bKmktM7JiWE0eLEfbmR81fIt5Ks8UQYAz38SQZbKLZKXF9ON1uj4kWVvl6fAVEey +emSZ7jKzjjwmsxyJkppO+3pBVAUQRy79VKSVnFVF2sTpCY/0mvq1cZUDmv570meH +rAp011pwo5sf9os2EKepjwEv2zatU9MJDVbip12Ja3y0WwnOeqhccWgpP2Um7Erf +vLUlRTsup6CSO5OjVFjJacLsyYnvjf4fEJbt53+EQkuq2sTZyZYi8vZpx4BxoP6C +Zac6gFFr4jj2Dk80MolJCkU8A1q+Kxo/BgDPenlAOH4m27n4Umh3KZXFl4ELCO8X +7/m9sItrCrMjJBpkgS4iTO5fTkeDW/uWGZ3YIsvgGzqiYdIkMEZpkeF3rZV6oc1p +3sRjTRKlcaD9thxbZta/S0b9xAd8kO4WLmwf03VNmJrVY8QoY5nY82g+HH/Kn75W +NaL6Zs08S3BJ+zlDF/sep8qW8JgMz3y8gdb/fQ4GemiU6l17N7vdyNgBYA0/zYbk +SoFvgjcD1ch7CiKgCRJgwHBnD5uZii95ps/Te4kBtgQYAQoAIBYhBAuHeaXlguOU +n5s8Lu77eFizlxqiBQJhd7ByAhsMAAoJEO77eFizlxqi6okMALqVxTHrzBVqD8lL +u3XCAEQWOdCzpFl8Vip9FbG11Ye9MY2hiCOrkeuv/fPyDNpwMP4wANhWJQYwp9SC +n8CD77Lye7Kt3JU93ZbsAzPRonbydY9+Wp0iuHzSzE091vRkGQsAx9Bt63d2PC3X +JmPfb+hqJtv70Vks2FppDJxsbZyFnCDpIe4RFwuUjfkEtQPPRrxnw3MJV04b+mnH +iJnMtmbjsAOE4o6WjHnGiBQTzoo7uC3UQvM7xcF0B4H4d0ZzRHIubQvdoARp0/GE +vtb2Kg96ZGkxCPksFwTn0fhu7jWQz4nYBUfs2Rs+s42jxcQaeHSfGpXTxEz1oAzm +Mufe00djjhxERW8AUrIaF+A3Cdzvga9IRqvEZd377E8x8xJhFONGSApOkVRHaBnQ +0n2WsF0GMOC8jmSoGatD3abc2+NRYkB7f1eH1H6qczcMu1d4uVwSnb+D5KV2iuGq +iSx2JbSboBV2v4sW+Mjvae6JMfVSy+IVvj7kj7jIx+1C6lr41A== +=UNJP +-----END PGP PRIVATE KEY BLOCK----- diff --git a/molecule/accounts/fixtures/gpg_key_1.pub b/molecule/accounts/fixtures/gpg_key_1.pub new file mode 100644 index 000000000..5ba168d04 --- /dev/null +++ b/molecule/accounts/fixtures/gpg_key_1.pub @@ -0,0 +1,41 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQGNBGF3sHIBDADlStPx5qQ18/rYBGmkBZSGAbxIo4D+eWM3Zg0q2xGZWGQ+eqph +LrDIRlxOR1fq1QPkCid/p79cGNPa4kLSh8rUiUoFY21tUjaIgSsLRtGyiiSlCc4b +I0/lbqenfSca0OsXKku/EaKMuuvgpGgqXypuY0zO3UVpPF0pW+gTWGwLd9VHPSvJ +X0czP/WITF8SYfj31sFjAy2mIsksiANclpq0OHqZwjU4IrxQC4HifeXvkQb+IxB7 +S8wUSwvm+Mg9f9wnB4s7/RN+1TdZqRxzzf7owGIbSMZX9DKQUy+gS0XSz+IwDdCi +Q6U28MFcpq2TRYj6d9QIwhm2ib/IzvKSq6otm1v/u0XlzJaNZL7m5b/0Mc6Il8Uw +M6nsNBUL9rc+wtP8DeheP+6ycfZGIyuym2RNlpa0317a6h4a9Q4Yi8EQluXHPbuU +HR8bp8GYm1iBLGFB9IOlbCES2fsZYNmHf3/Zk7MRound+o/hpDns1qd4CGT50Rrb +J22XF5WJqJoTsvkAEQEAAbQjbWFuYWxhIChNYW5hbGEpIDxjb250YWN0QG1hbmFs +YS5pbz6JAc4EEwEKADgWIQQLh3ml5YLjlJ+bPC7u+3hYs5caogUCYXewcgIbAwUL +CQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRDu+3hYs5caok1nDADHowTJHFvNEEOm +iZZtkQ/sK9QkXo6byzgvj5CQ6MFwzBEBhqF88GlgRvWXG7DltPF1NKxZ8GyiTFMH +GPUy44riM2VOrECjCvZUFnlmfG+oSRvWBW2kJ/k/P0xeQNe4SV78LoIKA/2myaAO +PqAofmsSahnhq26eSqgcNjzCGdArxne3ZsANKbnaAcv4NLjC5CBteCvOoh//zOTg +SdtqJoMN0O2nMXdnPN0Wirv4pSeE0fLBTeFN5VehOLewx06CKSD/HDERJcYG0ZjV +Ig/tQiMOpHbZOnNYvGWztUdB4Zg0L78XjPWoq4Y0UiuEwEWVXiq3NO19QtnLLUnG +iIwH4LEwNs4HoGUmFdca0iUCJRztW9Qb+ErP42P1rYCgqbdIcXIKLqo2M55NNp7q +HADD7WUHr38/Ra+CR/I0tsIVJ1/L3J4OVOD67dqxBUzZ0CtlEzj/PuCSdrYU2Qss +WZ+iqWXg/NveN/Mp4JsoTn1qSKWrxTaaWh1N91BJ9KbWopNft+O5AY0EYXewcgEM +AKWcTpVREp7uePf5qPu54cM10bBzyvryMRSAK8XECeN/r5+Ln4Syr/lV1gPXjIZu +08q6jeY88dFJ+1QuX2dfl4dAGBi84GC2pM8J7IuBUGSyA5qLO7290XZOIJniih+6 +I9GlVoD1DIp97ckEsdoWT/hjN0+3RlFrFjOgLqNj+mcdHrsw16gibeXQA3ZjktoB +GTPH/jp37Cn7o+YC2+SwVNNLeRvosYPY95fvMnPFKk/a4hflZ7VbHgqnnxZ43S9O +dsNsRe0vVi9PgHAc/FcFJEV1R+hdVRI62pUKfDx+z/gcaDH13CQUZdPlLp1uSOZV +952W6tkehUtlstBSPqlvgYNgTi7Rlo9GKC+G5tXCjq8dfxi3ILuBz9k8+Xvn+6c9 +GuFeLtIpkNpc0ccjBFYxFpwnENNkZxqZTjyZklN4JscMYrbcZBEsiYsseKuhuX6X +K0iVENOxyeiMF55XDhkciIwbdmSAk4yLfHO7SbvP/heyivzF+0ooAnSOj+mF6d8R +7wARAQABiQG2BBgBCgAgFiEEC4d5peWC45Sfmzwu7vt4WLOXGqIFAmF3sHICGwwA +CgkQ7vt4WLOXGqLqiQwAupXFMevMFWoPyUu7dcIARBY50LOkWXxWKn0VsbXVh70x +jaGII6uR66/98/IM2nAw/jAA2FYlBjCn1IKfwIPvsvJ7sq3clT3dluwDM9GidvJ1 +j35anSK4fNLMTT3W9GQZCwDH0G3rd3Y8LdcmY99v6Gom2/vRWSzYWmkMnGxtnIWc +IOkh7hEXC5SN+QS1A89GvGfDcwlXThv6aceImcy2ZuOwA4TijpaMecaIFBPOiju4 +LdRC8zvFwXQHgfh3RnNEci5tC92gBGnT8YS+1vYqD3pkaTEI+SwXBOfR+G7uNZDP +idgFR+zZGz6zjaPFxBp4dJ8aldPETPWgDOYy597TR2OOHERFbwBSshoX4DcJ3O+B +r0hGq8Rl3fvsTzHzEmEU40ZICk6RVEdoGdDSfZawXQYw4LyOZKgZq0Pdptzb41Fi +QHt/V4fUfqpzNwy7V3i5XBKdv4PkpXaK4aqJLHYltJugFXa/ixb4yO9p7okx9VLL +4hW+PuSPuMjH7ULqWvjU +=asgO +-----END PGP PUBLIC KEY BLOCK----- diff --git a/molecule/accounts/fixtures/gpg_key_2 b/molecule/accounts/fixtures/gpg_key_2 new file mode 100644 index 000000000..82d661110 --- /dev/null +++ b/molecule/accounts/fixtures/gpg_key_2 @@ -0,0 +1,81 @@ +-----BEGIN PGP PRIVATE KEY BLOCK----- + +lQVYBGF3s4EBDACuPRvK9zNKcQTyGogeB724WvHkK+FqSYAX6xzxyYkmB+Z46Jj2 +E2DZRzVWjo3aS1KbDtwoyT+F6Av9/6Qj5vi0pV7WWj8fvHZsdEtVW4W/Kigbxw/U +Fr7FOfAFur6TBFQGoaRr5LclrLpuPL1AfX5v7/gNmXX56kbLBDIjXzksop3R4Zr/ +Cnii46UdZVvDVRAgdgdPbmL4n3gnlfqYumoD6ZiHTjV1kNwby2DEncMhxLTXkkMM +XlO5W8tkgk301Kcq1tzQJNXQNMXGReAU4w0dLulFzbz1PtEZPX8gs/Yo2N3Dt+yz +l8xA6HshXupEjY6cXlTxwDioL+wZhzvJKqJctGYapElSbVgAeYz/6QRl4Nhv/tVi +5rN3k/b56O2XjfCJ4tVRbwiVbnA72J6n7ONAQHVzMMnTuepMVk6QRBDg03hd0irp +Bf3wF1NBrPule3HKTWEnNufAFQum54qNzmhyM0a1S7hGdT5oyyBZWRG5Hmr2ZszV +4leUL4HGp/RPJecAEQEAAQAL/i7uHrJIavQ+BMsBAnC0PRGOzWBbwVdTfMD0ftNR +KTOpJRaj7684APoFCATMWMDXUOSa2AnUStvSaIh9dsSEzbA6apTpsd7mcC8+E5xm +DlwzCqKQt1600aVluZSRfAs1OzyeBR9ad0oagAx5J7BbHNchl3pyPyiVRYQhGTAV +0dyH4GJLlefj9iJJlouYZWLzYmib4dQvM1EsAr0G1HyWmT98h6zKD/QelGqYGPRc +WdaamOsHZi/KqFpgsyPbRQwQypQlWdwn4dmS2GntryUJQBTktL1rbQgVqM47KhzV +aDsdNPxamQSMMwDO81R6AIbBLQ9XX40J5GJXScW9wyLArl2/LgvgkbFwOy20d6iA +nvRLMZhCFxWwzCDvG3OV+LB624Zlf2O6Be4cNLrN3u7hu9onu/hwz5r/a6+lIPuV +MgqRtOJBY6OeVljnLFPjG1yYWaScGWa7U0JESOEPpw2Z3cABwKPxMzZf7MzpzfCj +VAlwKsq/OVkhUUyBlcymZD2AAQYA0kVbxGixo4vqsSrUH+HzOSYwbZuSYhYl/3gz +uXC61FN9j4QYeRfmlcBN1Jmv0iehIq3acqsTwRcHXsmqdVVtkpvAKPvJrMIKLjQO +7m2D7n8b7pXPZZS5l4t89EGkE+j9fjh9exTgeygWEhCaGbCZ7EQBlys5aOu2/qO9 +sb1VHIIi1NEaJrhuqA6Jgc70dP4/BAqAiZGcCTi3rB1IAekPC5+f4s8Nzd3NlDQZ +aXPflXkH0d+CeJAAz4aWYAf891XnBgDUIbBcSUBnh7P44dU2uXEqVM7bjuOxdZPI +NV2eYSZSpNDlQZ2YV8Ksdn0wRJrKjJ+PUitsF54y+sjPvzy9pYFi0LfiA/VSOOYD +PMVoNDcDCivV4MQ1edxhdyeqjnRoCbajdr72S6FI04IlkR1fhwWwhM3jnBm7DEpn +u32KnJRwcDQfKQHV8Jk2UbB4dvRXINAzaV3+R8/ln6lZ+jugAx4z8N1xhl2r4qJb +8tDztKGfyQ9zC5xi2hsqQJVWyQZPsAEF/RCxf0Hyf3Fslam4fhJtG/p8jENWqyCb +YDnBSCF6w7TZLA+0iU6TUfA8INTl7RGJZYDgPUVX/+OxRihMbYcTzWMG49BhfxgT +FWklPV7NgMOFoEO3JdMj3ZZUdffuGVGumngxoGVoU/N4PBjH8runiJNaR4gpHemj +IvaX1M3EnZmW4OGRfR0Kxi3cTHVzw9TzcWKJbBh+oiY5vyzssE3aceUYI31ZT0VL +Pw5OD1fpvTFHFjRm6gSAvzxDJ8B7ROOxgNaDtCNtYW5hbGEgKE1hbmFsYSkgPGNv +bnRhY3RAbWFuYWxhLmlvPokBzgQTAQoAOBYhBM9jSNw6cQLpFO7KMTwKoM1uM4La +BQJhd7OBAhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEDwKoM1uM4La4zwL +/RCST8hel4IttwI8fou4lcbuc0Vtn+G0+x8QEGRh95TGhlW3gOsHajjjvbuR+w2i +qlNQgihqzWDT29TLAhMOKasQRxJ9Zgd9J/aZOsAFg47Sbr3+gW2E4y/26u9oerJC +iK2F7xsDlKfbgCfRcnmgge2keaZXcLdmLc3XjUqWJP4CakVAEf7lQItec5fwRdM8 +fzNZnlmSTtt9P/upZ//O3/Dyc7KQ7Bn0Yz5s0ufxnZHgpteyVXjN5hJkyIanbcQt ++ysPh7s4SgDXjvw92yNf2u1B7qfijmIeuvi2wh9H1B+OhJ5n6+OjpmPifXaEk3nO +ZCwMKArcQyj9n4I0PDmDv3YPfpDM24OU2iJ5fNGz/7INi53gAB6Nb5nODCofo9QA +7MNy15hKyYuLaDrpY9eqc8jiKEBgYuIEWks99n7Ci1/TPLc7eoGthxYzLLnfULVj +blLe7BjqIc2H/xFehTWqmSeNRW+0JOB/H0oQkd0O8qCU9LXG1wpUfR8GzOWtUluL +0J0FWARhd7OBAQwAvRf6bbuxnuuFvPo2IjqcBGtilhhf5TUcoBJb5H1CWSMNMGZV +L3IVZMcDmQxUy9CEZ3ZyYJzN47IcbO+0RgLFTI97QzNdXiawFNh/HWv3zeVil0+6 +Bcp0BaNYrxpE2IllUnDldvZkM3gg+4cEVYVX5MP3o9uvwAWRC/+IGgxy313JWLhp +/cKHQ3d7E3On5p4RtEGEIRymR/3RL7K9PSyFV8x8uFA854ijzf7yVPpKmIgVbtT2 +29xfph2Jz3JH18HdhDH6U3CD7CZ3AbMEcUYnnRvje3x8qBm0NPabLVOibduenFEi +/hQ9sVVFWtW0tyQAARwB6ERgIAEOGXFcsGvXqjiPmjPYBsA8y3jzkOWhR5EF0Kuv +kRgQGbf2kkYq/qbImjujHc9RHgVobh26YrWkZGJ4t5q7sxjFuc8WEJ6AaYEH+vHs +0c8lGOyhgOlf501RHL1YkCYiockUS3Xyf6MLOIvw3XBwsMVFVXOln6jI9v277bnA +UKwiGF0ZFYVGZOyLABEBAAEAC/4pzD+Uev03sjsFO0+1ADyVc4E+yVOFMFjL/1Ll +rlR4rJlRPgWNb8vP03f1oDasOMLTtehxd6fBMZE7+T5hjWI8Wqj2AUgdtDKO4Q40 +HDYSAqbo6HwnpIlB58oGJqnaLYDCmOb4BV2/zMmJn94y4z8696BpTXnLWc+mlczp +aSAJRMtpe5YePB43KRWBBrsx7HXgYO0KfrE4z5+qSfmvqIQvFKnq+f2Edn0y3yyE +4TCVB9uo/JU2oz9XUkcwnkPIKvdhZGoDVxH8eOV6ErqFcmxwy7CXdGEjN4kvVOKP +Qj8xQ5F2yay02vBF5khVYceZWr3nNtygEc+5ucH1rwvk0x2CgAIkz1ipSa/Y9NJQ +r+x3c/VjZpK8f58mLyE+2GDLKzKC9WBW64SWbUGYI+wfiNBELryN0Z5zfIuDWYUu +bNFB6/nytI0uMFL43B4uzSOlh3emu5anmHHW8lbKg6JLEI2rlLDVZlmmkmIBIiJN +eQKUmIpENaYRv1ejxfOYejNzKZ0GANfQ1hb4tAz44a1Zas4YaN9TSXFujK0joKkv ++G30TLm3U+1UKnXXDXNTfMRMAtcKY26yAj9WtKNt51fPRpsTg5SO8nrvSbsqwqpO +P4LbuBlZkpcpZdaf4p9YCCEqCqiAD/jiNFaxDyJHsEaPme/7SZZmxC6vF3NAPYeS +xY5AokJPcLPhwYRtu5n4RlvPZ1DMaLo01GvYW1u/xobzCdWdbD2xFcMie1/JKqiT +qqVd/3PEcLJrLFAxZKVWuNWuHr0o/wYA4E1lKoVgx0L3hb0SckYAWiqVg0YCAzO1 +N5rP4NrOqm94vQRZTS2Jt21/L6AKeoI5G6Ns6nk8Mut2Sd9X9OZXLxd5yDew//zD +7HnSwBN8dUIC/qC1EIhjhXMtU6Yqb15rQtoxFvqR3C6tDv3Hvwa8KF1c/1pHZFi9 +WrY9RAw2ewGPzuDhxDITZ8SLcWJYmoxfmlzOsfUzVmWpC04izN+ET6DOXCMM+KBF +slL9Cxwo3edTk7y89SvSD6xk9cqFXtB1BgDPfhTRaWP25sq4eSJetbNhKBRu8mzl +rMvMMQkO+oEkKOeVXhieKhwNKvoTPM/PNPzbcUktJwnOJH1lmSFZbU4Jrjh8pjH7 +0rNVEEIEsu4mCFDuQXMaojQruZeFr59hZhsVa43UGJZ4A/qS7S56KEWHqY8p19zh +uT1/5wvFjx6qWcdYNjFsVkb5HHPPDnwoH4zOS1xF72xdZsvP5iiwlI3trCdiM9ul +KHWMla2wu9RMuWHqQKq3Y/5cQ8kv9m+nJlPdT4kBtgQYAQoAIBYhBM9jSNw6cQLp +FO7KMTwKoM1uM4LaBQJhd7OBAhsMAAoJEDwKoM1uM4LaGWcL+wcYjh6vjsp9DgoW +t3bQY/61U3JG9bGsQnOCNWncLeNz0tLELWQg/ZVBWApQtkPLCZOyY8qIy7a4brim +xLZLQtNU97PYpU/GrnTMsBQ7GKGHGXg26C/jnzn8go1lV2NG37npnP9xAvtJ+NID +oSJD5kUX3x1zWIbN/TsYctf8HhKYMmAY8sQBswSQHCvvk7BwPfExNQ0aiAFgf5CU +E+9Qf5c17NeLjv1VvAQKv3tiKXy0anhS3pJQ1aCcpPUmfEFK95FuHNBNNda26AVa +HNmRzYD72funJtj8dWdXOjdfilQL7oZLhvSxk7ghlu2xMRKGms8KmI35+kV+MbRA +rUm8FaDngdO9n/bukWluqLwSzEDUbfdSfOmQH5RVTNHq5CbVUGf8dYqF8W8Ab6Ew +T0iktQ0EHlTJvFzxXD4j9kuaarh2p/NWK9aukRdqxgY5LBugNN1MSIZK0Jc5WpTc +IU+GA3mNqF6vEXd1nGmRqKClQ80bRZOPl/aRy/d3LmGk5VzLXw== +=PE/J +-----END PGP PRIVATE KEY BLOCK----- diff --git a/molecule/accounts/fixtures/gpg_key_2.pub b/molecule/accounts/fixtures/gpg_key_2.pub new file mode 100644 index 000000000..d3fb24f35 --- /dev/null +++ b/molecule/accounts/fixtures/gpg_key_2.pub @@ -0,0 +1,41 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQGNBGF3s4EBDACuPRvK9zNKcQTyGogeB724WvHkK+FqSYAX6xzxyYkmB+Z46Jj2 +E2DZRzVWjo3aS1KbDtwoyT+F6Av9/6Qj5vi0pV7WWj8fvHZsdEtVW4W/Kigbxw/U +Fr7FOfAFur6TBFQGoaRr5LclrLpuPL1AfX5v7/gNmXX56kbLBDIjXzksop3R4Zr/ +Cnii46UdZVvDVRAgdgdPbmL4n3gnlfqYumoD6ZiHTjV1kNwby2DEncMhxLTXkkMM +XlO5W8tkgk301Kcq1tzQJNXQNMXGReAU4w0dLulFzbz1PtEZPX8gs/Yo2N3Dt+yz +l8xA6HshXupEjY6cXlTxwDioL+wZhzvJKqJctGYapElSbVgAeYz/6QRl4Nhv/tVi +5rN3k/b56O2XjfCJ4tVRbwiVbnA72J6n7ONAQHVzMMnTuepMVk6QRBDg03hd0irp +Bf3wF1NBrPule3HKTWEnNufAFQum54qNzmhyM0a1S7hGdT5oyyBZWRG5Hmr2ZszV +4leUL4HGp/RPJecAEQEAAbQjbWFuYWxhIChNYW5hbGEpIDxjb250YWN0QG1hbmFs +YS5pbz6JAc4EEwEKADgWIQTPY0jcOnEC6RTuyjE8CqDNbjOC2gUCYXezgQIbAwUL +CQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRA8CqDNbjOC2uM8C/0Qkk/IXpeCLbcC +PH6LuJXG7nNFbZ/htPsfEBBkYfeUxoZVt4DrB2o44727kfsNoqpTUIIoas1g09vU +ywITDimrEEcSfWYHfSf2mTrABYOO0m69/oFthOMv9urvaHqyQoithe8bA5Sn24An +0XJ5oIHtpHmmV3C3Zi3N141KliT+AmpFQBH+5UCLXnOX8EXTPH8zWZ5Zkk7bfT/7 +qWf/zt/w8nOykOwZ9GM+bNLn8Z2R4KbXslV4zeYSZMiGp23ELfsrD4e7OEoA1478 +PdsjX9rtQe6n4o5iHrr4tsIfR9QfjoSeZ+vjo6Zj4n12hJN5zmQsDCgK3EMo/Z+C +NDw5g792D36QzNuDlNoieXzRs/+yDYud4AAejW+ZzgwqH6PUAOzDcteYSsmLi2g6 +6WPXqnPI4ihAYGLiBFpLPfZ+wotf0zy3O3qBrYcWMyy531C1Y25S3uwY6iHNh/8R +XoU1qpknjUVvtCTgfx9KEJHdDvKglPS1xtcKVH0fBszlrVJbi9C5AY0EYXezgQEM +AL0X+m27sZ7rhbz6NiI6nARrYpYYX+U1HKASW+R9QlkjDTBmVS9yFWTHA5kMVMvQ +hGd2cmCczeOyHGzvtEYCxUyPe0MzXV4msBTYfx1r983lYpdPugXKdAWjWK8aRNiJ +ZVJw5Xb2ZDN4IPuHBFWFV+TD96Pbr8AFkQv/iBoMct9dyVi4af3Ch0N3exNzp+ae +EbRBhCEcpkf90S+yvT0shVfMfLhQPOeIo83+8lT6SpiIFW7U9tvcX6Ydic9yR9fB +3YQx+lNwg+wmdwGzBHFGJ50b43t8fKgZtDT2my1Tom3bnpxRIv4UPbFVRVrVtLck +AAEcAehEYCABDhlxXLBr16o4j5oz2AbAPMt485DloUeRBdCrr5EYEBm39pJGKv6m +yJo7ox3PUR4FaG4dumK1pGRieLeau7MYxbnPFhCegGmBB/rx7NHPJRjsoYDpX+dN +URy9WJAmIqHJFEt18n+jCziL8N1wcLDFRVVzpZ+oyPb9u+25wFCsIhhdGRWFRmTs +iwARAQABiQG2BBgBCgAgFiEEz2NI3DpxAukU7soxPAqgzW4zgtoFAmF3s4ECGwwA +CgkQPAqgzW4zgtoZZwv7BxiOHq+Oyn0OCha3dtBj/rVTckb1saxCc4I1adwt43PS +0sQtZCD9lUFYClC2Q8sJk7JjyojLtrhuuKbEtktC01T3s9ilT8audMywFDsYoYcZ +eDboL+OfOfyCjWVXY0bfuemc/3EC+0n40gOhIkPmRRffHXNYhs39Oxhy1/weEpgy +YBjyxAGzBJAcK++TsHA98TE1DRqIAWB/kJQT71B/lzXs14uO/VW8BAq/e2IpfLRq +eFLeklDVoJyk9SZ8QUr3kW4c0E011rboBVoc2ZHNgPvZ+6cm2Px1Z1c6N1+KVAvu +hkuG9LGTuCGW7bExEoaazwqYjfn6RX4xtECtSbwVoOeB072f9u6RaW6ovBLMQNRt +91J86ZAflFVM0erkJtVQZ/x1ioXxbwBvoTBPSKS1DQQeVMm8XPFcPiP2S5pquHan +81Yr1q6RF2rGBjksG6A03UxIhkrQlzlalNwhT4YDeY2oXq8Rd3WcaZGooKVDzRtF +k4+X9pHL93cuYaTlXMtf +=LMzL +-----END PGP PUBLIC KEY BLOCK----- diff --git a/roles/accounts/tests/fixtures/keys/user_1 b/molecule/accounts/fixtures/key_1 similarity index 100% rename from roles/accounts/tests/fixtures/keys/user_1 rename to molecule/accounts/fixtures/key_1 diff --git a/roles/accounts/tests/fixtures/keys/user_1.pub b/molecule/accounts/fixtures/key_1.pub similarity index 100% rename from roles/accounts/tests/fixtures/keys/user_1.pub rename to molecule/accounts/fixtures/key_1.pub diff --git a/roles/accounts/tests/fixtures/keys/user_2 b/molecule/accounts/fixtures/key_2 similarity index 100% rename from roles/accounts/tests/fixtures/keys/user_2 rename to molecule/accounts/fixtures/key_2 diff --git a/roles/accounts/tests/fixtures/keys/user_2.pub b/molecule/accounts/fixtures/key_2.pub similarity index 100% rename from roles/accounts/tests/fixtures/keys/user_2.pub rename to molecule/accounts/fixtures/key_2.pub diff --git a/molecule/accounts/goss/groups.yml.j2 b/molecule/accounts/goss/groups.yml.j2 new file mode 100644 index 000000000..1b86c81b4 --- /dev/null +++ b/molecule/accounts/goss/groups.yml.j2 @@ -0,0 +1,29 @@ +--- + +group: + # Short syntax + group_short_syntax: + exists: true + # Simple + group_simple: + exists: true + # Verbose syntax + group_verbose_syntax: + exists: true + gid: 1337 + # Flatten + group_flatten: + exists: true + # State + group_state_present_implicit: + exists: true + group_state_present: + exists: true + group_state_absent: + exists: false + group_state_absent_existing: + exists: false + group_state_ignore: + exists: false + group_state_ignore_existing: + exists: true diff --git a/molecule/accounts/goss/users.yml.j2 b/molecule/accounts/goss/users.yml.j2 new file mode 100644 index 000000000..7c83414d2 --- /dev/null +++ b/molecule/accounts/goss/users.yml.j2 @@ -0,0 +1,37 @@ +--- + +user: + + # Short syntax + user_short_syntax: + exists: true + home: /home/user_short_syntax + groups: + - user_short_syntax + # Simple + user_simple: + exists: true + home: /home/user_simple + groups: + - user_simple + # Verbose syntax + user_verbose_syntax: + exists: true + groups: + - users_group + # Flatten + user_flatten: + exists: true + # State + user_state_present_implicit: + exists: true + user_state_present: + exists: true + user_state_absent: + exists: false + user_state_absent_existing: + exists: false + user_state_ignore: + exists: false + user_state_ignore_existing: + exists: true diff --git a/molecule/accounts/goss/users_authorized_keys.yml.j2 b/molecule/accounts/goss/users_authorized_keys.yml.j2 new file mode 100644 index 000000000..98e8c809f --- /dev/null +++ b/molecule/accounts/goss/users_authorized_keys.yml.j2 @@ -0,0 +1,61 @@ +--- + +user: + + # Verbose syntax + user_ak_verbose_syntax: + exists: true + # Flatten + user_ak_flatten: + exists: true + # Multiple + user_ak_multiple: + exists: true + # File + user_ak_file: + exists: true + # State + user_ak_state_ignore: + exists: false + +file: + + # Verbose syntax + /home/user_ak_verbose_syntax/.ssh/authorized_keys: + exists: true + filetype: file + owner: user_ak_verbose_syntax + mode: "0600" + contains: + - "{{ lookup('file', 'fixtures/key_1.pub') }}" + # Flatten + /home/user_ak_flatten/.ssh/authorized_keys: + exists: true + filetype: file + owner: user_ak_flatten + mode: "0600" + contains: + - "{{ lookup('file', 'fixtures/key_1.pub') }}" + # Multiple + /home/user_ak_multiple/.ssh/authorized_keys: + exists: true + filetype: file + owner: user_ak_multiple + mode: "0600" + contains: + - "{{ lookup('file', 'fixtures/key_1.pub') }}" + - "{{ lookup('file', 'fixtures/key_2.pub') }}" + # File + /home/user_ak_file/.ssh/authorized_keys: + exists: false + /home/user_ak_file/.ssh/authorized_keys2: + exists: true + filetype: file + owner: user_ak_file + mode: "0600" + contains: + - "{{ lookup('file', 'fixtures/key_1.pub') }}" + - "!{{ lookup('file', 'fixtures/key_2.pub') }}" + # State + /home/user_ak_state_ignore/.ssh/authorized_keys: + exists: false diff --git a/molecule/accounts/goss/users_gpg_keys.yml.j2 b/molecule/accounts/goss/users_gpg_keys.yml.j2 new file mode 100644 index 000000000..e97355fc4 --- /dev/null +++ b/molecule/accounts/goss/users_gpg_keys.yml.j2 @@ -0,0 +1,96 @@ +--- + +user: + + # None + user_gk_none: + exists: true + # Public + user_gk_public: + exists: true + # Secret + user_gk_secret: + exists: true + # Trust + user_gk_trust: + exists: true + # Verbose syntax + user_gk_verbose_syntax: + exists: true + # Flatten + user_gk_flatten: + exists: true + # Multiple + user_gk_multiple: + exists: true + # State + user_gk_state_ignore: + exists: false + +command: + + # None + su user_gk_none -c 'gpg --list-keys EEFB7858B3971AA2': + exit-status: 2 + su user_gk_none -c 'gpg --list-secret-keys EEFB7858B3971AA2': + exit-status: 2 + # Public + su user_gk_public -c 'gpg --list-keys EEFB7858B3971AA2': + exit-status: 0 + stdout: + - EEFB7858B3971AA2 + su user_gk_public -c 'gpg --list-secret-keys EEFB7858B3971AA2': + exit-status: 2 + # Secret + su user_gk_secret -c 'gpg --list-keys EEFB7858B3971AA2': + exit-status: 0 + stdout: + - EEFB7858B3971AA2 + su user_gk_secret -c 'gpg --list-secret-keys EEFB7858B3971AA2': + exit-status: 0 + stdout: + - EEFB7858B3971AA2 + # Trust + su user_gk_trust -c 'gpg --list-keys EEFB7858B3971AA2': + exit-status: 0 + stdout: + - EEFB7858B3971AA2 + su user_gk_trust -c 'gpg --export-ownertrust': + exit-status: 0 + stdout: + - EEFB7858B3971AA2 + # Verbose syntax + su user_gk_verbose_syntax -c 'gpg --list-keys EEFB7858B3971AA2': + exit-status: 0 + stdout: + - EEFB7858B3971AA2 + su user_gk_verbose_syntax -c 'gpg --list-secret-keys EEFB7858B3971AA2': + exit-status: 0 + stdout: + - EEFB7858B3971AA2 + # Flatten + su user_gk_flatten -c 'gpg --list-keys EEFB7858B3971AA2': + exit-status: 0 + stdout: + - EEFB7858B3971AA2 + su user_gk_flatten -c 'gpg --list-secret-keys EEFB7858B3971AA2': + exit-status: 0 + stdout: + - EEFB7858B3971AA2 + # Multiple + su user_gk_multiple -c 'gpg --list-keys EEFB7858B3971AA2': + exit-status: 0 + stdout: + - EEFB7858B3971AA2 + su user_gk_multiple -c 'gpg --list-secret-keys EEFB7858B3971AA2': + exit-status: 0 + stdout: + - EEFB7858B3971AA2 + su user_gk_multiple -c 'gpg --list-keys 3C0AA0CD6E3382DA': + exit-status: 0 + stdout: + - 3C0AA0CD6E3382DA + su user_gk_multiple -c 'gpg --list-secret-keys 3C0AA0CD6E3382DA': + exit-status: 0 + stdout: + - 3C0AA0CD6E3382DA diff --git a/molecule/accounts/goss/users_keys.yml.j2 b/molecule/accounts/goss/users_keys.yml.j2 new file mode 100644 index 000000000..c4f9f7b9c --- /dev/null +++ b/molecule/accounts/goss/users_keys.yml.j2 @@ -0,0 +1,171 @@ +--- + +user: + + # None + user_k_none: + exists: true + # Private + user_k_private: + exists: true + # Public + user_k_public: + exists: true + # Verbose syntax + user_k_verbose_syntax: + exists: true + # Flatten + user_k_flatten: + exists: true + # Multiple + user_k_multiple: + exists: true + # State + user_k_state_ignore: + exists: false + +file: + + # None + /home/user_k_none/.ssh: + exists: true + filetype: directory + owner: user_k_none + group: user_k_none + mode: "0700" + /home/user_k_none/.ssh/id_rsa: + exists: false + /home/user_k_none/.ssh/id_rsa.pub: + exists: false + # Private + /home/user_k_private/.ssh: + exists: true + filetype: directory + owner: user_k_private + group: user_k_private + mode: "0700" + /home/user_k_private/.ssh/id_rsa: + exists: true + filetype: file + owner: user_k_private + group: user_k_private + mode: "0600" + contains: +{% for line in lookup('file', 'fixtures/key_1').splitlines() %} + - "{{ line }}" +{% endfor %} + /home/user_k_private/.ssh/id_rsa.pub: + exists: false + # Public + /home/user_k_public/.ssh: + exists: true + filetype: directory + owner: user_k_public + group: user_k_public + mode: "0700" + /home/user_k_public/.ssh/id_rsa: + exists: false + /home/user_k_public/.ssh/id_rsa.pub: + exists: true + filetype: file + owner: user_k_public + group: user_k_public + mode: "0644" + contains: + - "{{ lookup('file', 'fixtures/key_1.pub') }}" + # Verbose syntax + /home/user_k_verbose_syntax/.ssh: + exists: true + filetype: directory + owner: user_k_verbose_syntax + group: user_k_verbose_syntax + mode: "0700" + /home/user_k_verbose_syntax/.ssh/id_rsa: + exists: true + filetype: file + owner: user_k_verbose_syntax + group: user_k_verbose_syntax + mode: "0600" + contains: +{% for line in lookup('file', 'fixtures/key_1').splitlines() %} + - "{{ line }}" +{% endfor %} + /home/user_k_verbose_syntax/.ssh/id_rsa.pub: + exists: true + filetype: file + owner: user_k_verbose_syntax + group: user_k_verbose_syntax + mode: "0644" + contains: + - "{{ lookup('file', 'fixtures/key_1.pub') }}" + # Flatten + /home/user_k_flatten/.ssh: + exists: true + filetype: directory + owner: user_k_flatten + group: user_k_flatten + mode: "0700" + /home/user_k_flatten/.ssh/id_rsa: + exists: true + filetype: file + owner: user_k_flatten + group: user_k_flatten + mode: "0600" + contains: +{% for line in lookup('file', 'fixtures/key_1').splitlines() %} + - "{{ line }}" +{% endfor %} + /home/user_k_flatten/.ssh/id_rsa.pub: + exists: true + filetype: file + owner: user_k_flatten + group: user_k_flatten + mode: "0644" + contains: + - "{{ lookup('file', 'fixtures/key_1.pub') }}" + # Multiple + /home/user_k_multiple/.ssh: + exists: true + filetype: directory + owner: user_k_multiple + group: user_k_multiple + mode: "0700" + /home/user_k_multiple/.ssh/id_rsa_1: + exists: true + filetype: file + owner: user_k_multiple + group: user_k_multiple + mode: "0600" + contains: +{% for line in lookup('file', 'fixtures/key_1').splitlines() %} + - "{{ line }}" +{% endfor %} + /home/user_k_multiple/.ssh/id_rsa_1.pub: + exists: true + filetype: file + owner: user_k_multiple + group: user_k_multiple + mode: "0644" + contains: + - "{{ lookup('file', 'fixtures/key_1.pub') }}" + /home/user_k_multiple/.ssh/id_rsa_2: + exists: true + filetype: file + owner: user_k_multiple + group: user_k_multiple + mode: "0600" + contains: +{% for line in lookup('file', 'fixtures/key_2').splitlines() %} + - "{{ line }}" +{% endfor %} + /home/user_k_multiple/.ssh/id_rsa_2.pub: + exists: true + filetype: file + owner: user_k_multiple + group: user_k_multiple + mode: "0644" + contains: + - "{{ lookup('file', 'fixtures/key_2.pub') }}" + # State + /home/user_k_state_ignore/.ssh: + exists: false diff --git a/roles/deploy/tests/fixtures/app/dir/dir/dir_shared/file b/molecule/accounts/molecule.yml similarity index 100% rename from roles/deploy/tests/fixtures/app/dir/dir/dir_shared/file rename to molecule/accounts/molecule.yml diff --git a/molecule/alternatives/converge.yml b/molecule/alternatives/converge.yml new file mode 100644 index 000000000..e35544938 --- /dev/null +++ b/molecule/alternatives/converge.yml @@ -0,0 +1,42 @@ +--- + +############## +# Selections # +############## + +- name: Selections + tags: [selections] + hosts: debian + tasks: + - name: Packages + apt: + name: [nano, ed, less] + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - name: Alternatives + alternatives: + name: "{{ item[0] }}" + path: "{{ item[1] }}" + loop: [[editor, /bin/nano], [pico, /bin/nano], [pager, /bin/more]] + - block: + - name: Role + import_role: + name: manala.roles.alternatives + vars: + manala_alternatives_selections: + - selection: editor + path: /bin/ed + # Flatten + - + - selection: pico + path: /bin/ed + # State + - selection: pager + path: /bin/less + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/selections.yml.j2') }}" diff --git a/molecule/alternatives/goss/selections.yml.j2 b/molecule/alternatives/goss/selections.yml.j2 new file mode 100644 index 000000000..a6e06b2f6 --- /dev/null +++ b/molecule/alternatives/goss/selections.yml.j2 @@ -0,0 +1,16 @@ +--- + +command: + + update-alternatives --query editor: + exit-status: 0 + stdout: + - "Value: /bin/ed" + update-alternatives --query pico: + exit-status: 0 + stdout: + - "Value: /bin/ed" + update-alternatives --query pager: + exit-status: 0 + stdout: + - "Value: /bin/more" diff --git a/roles/deploy/tests/fixtures/app/dir/dir/file_shared b/molecule/alternatives/molecule.yml similarity index 100% rename from roles/deploy/tests/fixtures/app/dir/dir/file_shared rename to molecule/alternatives/molecule.yml diff --git a/molecule/ansible/converge.yml b/molecule/ansible/converge.yml new file mode 100644 index 000000000..c428a8610 --- /dev/null +++ b/molecule/ansible/converge.yml @@ -0,0 +1,277 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.ansible + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +######### +# Hosts # +######### + +- name: Hosts + tags: [hosts] + hosts: debian + vars: + tests_dir: /molecule/ansible/hosts + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Content + import_role: + name: manala.roles.ansible + tasks_from: hosts + vars: + manala_ansible_hosts_file: "{{ tests_dir }}/content" + manala_ansible_hosts_template: ~ + manala_ansible_hosts: | + Content + - name: Role - Template + import_role: + name: manala.roles.ansible + tasks_from: hosts + vars: + manala_ansible_hosts_file: "{{ tests_dir }}/template" + manala_ansible_hosts_template: fixtures/template.j2 + manala_ansible_hosts: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/hosts.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/ansible/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Content + import_role: + name: manala.roles.ansible + tasks_from: config + vars: + manala_ansible_config_file: "{{ tests_dir }}/content" + manala_ansible_config_template: ~ + manala_ansible_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.ansible + tasks_from: config + vars: + manala_ansible_config_file: "{{ tests_dir }}/template" + manala_ansible_config_template: fixtures/template.j2 + manala_ansible_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +############# +# Host Vars # +############# + +- name: Host Vars + tags: [host_vars] + hosts: debian + vars: + tests_dir: /molecule/ansible/host_vars + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/foo, exclusive/bar, exclusive/baz, exclusive/qux, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.ansible + tasks_from: host_vars + vars: + manala_ansible_host_vars_exclusive: false + manala_ansible_host_vars_dir: "{{ tests_dir }}/default" + manala_ansible_host_vars_defaults: {} + manala_ansible_host_vars: + # Content + - file: content + vars: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.ansible + tasks_from: host_vars + vars: + manala_ansible_host_vars_exclusive: false + manala_ansible_host_vars_dir: "{{ tests_dir }}/defaults" + manala_ansible_host_vars_defaults: + template: fixtures/template.j2 + manala_ansible_host_vars: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.ansible + tasks_from: host_vars + vars: + manala_ansible_host_vars_exclusive: true + manala_ansible_host_vars_dir: "{{ tests_dir }}/exclusive" + manala_ansible_host_vars_defaults: {} + manala_ansible_host_vars: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/host_vars.yml.j2') }}" + +############## +# Group Vars # +############## + +- name: Group Vars + tags: [group_vars] + hosts: debian + vars: + tests_dir: /molecule/ansible/group_vars + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/foo, exclusive/bar, exclusive/baz, exclusive/qux, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.ansible + tasks_from: group_vars + vars: + manala_ansible_group_vars_exclusive: false + manala_ansible_group_vars_dir: "{{ tests_dir }}/default" + manala_ansible_group_vars_defaults: {} + manala_ansible_group_vars: + # Content + - file: content + vars: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.ansible + tasks_from: group_vars + vars: + manala_ansible_group_vars_exclusive: false + manala_ansible_group_vars_dir: "{{ tests_dir }}/defaults" + manala_ansible_group_vars_defaults: + template: fixtures/template.j2 + manala_ansible_group_vars: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.ansible + tasks_from: group_vars + vars: + manala_ansible_group_vars_exclusive: true + manala_ansible_group_vars_dir: "{{ tests_dir }}/exclusive" + manala_ansible_group_vars_defaults: {} + manala_ansible_group_vars: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/group_vars.yml.j2') }}" diff --git a/molecule/ansible/fixtures/template.j2 b/molecule/ansible/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/ansible/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/ansible/fixtures/template_file.j2 b/molecule/ansible/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/ansible/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/ansible/goss/config.yml.j2 b/molecule/ansible/goss/config.yml.j2 new file mode 100644 index 000000000..30ac39316 --- /dev/null +++ b/molecule/ansible/goss/config.yml.j2 @@ -0,0 +1,19 @@ +--- + +file: + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/ansible/goss/default.yml.j2 b/molecule/ansible/goss/default.yml.j2 new file mode 100644 index 000000000..feff93b69 --- /dev/null +++ b/molecule/ansible/goss/default.yml.j2 @@ -0,0 +1,15 @@ +--- + +package: + ansible: + installed: true + +command: + dpkg -s ansible: + exit-status: 0 + stdout: + - "/^Version: \\d+/" + ansible --version: + exit-status: 0 + stdout: + - "/^ansible \\d+\\.\\d+\\.\\d+/" diff --git a/molecule/ansible/goss/group_vars.yml.j2 b/molecule/ansible/goss/group_vars.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/ansible/goss/group_vars.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/ansible/goss/host_vars.yml.j2 b/molecule/ansible/goss/host_vars.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/ansible/goss/host_vars.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/ansible/goss/hosts.yml.j2 b/molecule/ansible/goss/hosts.yml.j2 new file mode 100644 index 000000000..30ac39316 --- /dev/null +++ b/molecule/ansible/goss/hosts.yml.j2 @@ -0,0 +1,19 @@ +--- + +file: + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/roles/deploy/tests/fixtures/app/dir/dir_shared/file b/molecule/ansible/molecule.yml similarity index 100% rename from roles/deploy/tests/fixtures/app/dir/dir_shared/file rename to molecule/ansible/molecule.yml diff --git a/molecule/ansible/prepare.yml b/molecule/ansible/prepare.yml new file mode 100644 index 000000000..cec7aa26c --- /dev/null +++ b/molecule/ansible/prepare.yml @@ -0,0 +1,12 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - ansible@backports + when: ansible_distribution_release in ['stretch'] diff --git a/molecule/ansible_galaxy/converge.yml b/molecule/ansible_galaxy/converge.yml new file mode 100644 index 000000000..62f6516fe --- /dev/null +++ b/molecule/ansible_galaxy/converge.yml @@ -0,0 +1,26 @@ +--- + +######### +# Roles # +######### + +- name: Roles + tags: [roles] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.ansible_galaxy + tasks_from: roles + vars: + manala_ansible_galaxy_roles: + - ansistrano.deploy + - jdauphant.nginx + - src: jdauphant.nginx + version: v1.11.4 + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/roles.yml.j2') }}" diff --git a/roles/ansible_galaxy/tests/0000_default.goss.yml b/molecule/ansible_galaxy/goss/roles.yml.j2 similarity index 100% rename from roles/ansible_galaxy/tests/0000_default.goss.yml rename to molecule/ansible_galaxy/goss/roles.yml.j2 diff --git a/roles/deploy/tests/fixtures/app/dir/file b/molecule/ansible_galaxy/molecule.yml similarity index 100% rename from roles/deploy/tests/fixtures/app/dir/file rename to molecule/ansible_galaxy/molecule.yml diff --git a/molecule/ansible_galaxy/prepare.yml b/molecule/ansible_galaxy/prepare.yml new file mode 100644 index 000000000..dbb1338dc --- /dev/null +++ b/molecule/ansible_galaxy/prepare.yml @@ -0,0 +1,15 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - ansible@backports + when: ansible_distribution_release in ['stretch'] + - name: Ansible + import_role: + name: manala.roles.ansible diff --git a/molecule/apparmor/converge.yml b/molecule/apparmor/converge.yml new file mode 100644 index 000000000..4f1233f68 --- /dev/null +++ b/molecule/apparmor/converge.yml @@ -0,0 +1,109 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.apparmor + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/apparmor/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.apparmor + vars: + manala_apparmor_configs_exclusive: false + manala_apparmor_configs_dir: "{{ tests_dir }}/default" + manala_apparmor_configs_defaults: {} + manala_apparmor_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.apparmor + tasks_from: configs + vars: + manala_apparmor_configs_exclusive: false + manala_apparmor_configs_dir: "{{ tests_dir }}/defaults" + manala_apparmor_configs_defaults: + template: fixtures/template.j2 + manala_apparmor_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.apparmor + tasks_from: configs + vars: + manala_apparmor_configs_exclusive: true + manala_apparmor_configs_dir: "{{ tests_dir }}/exclusive" + manala_apparmor_configs_defaults: {} + manala_apparmor_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" diff --git a/molecule/apparmor/fixtures/template.j2 b/molecule/apparmor/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/apparmor/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/apparmor/fixtures/template_file.j2 b/molecule/apparmor/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/apparmor/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/apparmor/goss/configs.yml.j2 b/molecule/apparmor/goss/configs.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/apparmor/goss/configs.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/roles/apparmor/tests/0100_install.goss.yml b/molecule/apparmor/goss/default.yml.j2 similarity index 100% rename from roles/apparmor/tests/0100_install.goss.yml rename to molecule/apparmor/goss/default.yml.j2 diff --git a/roles/deploy/tests/fixtures/app/dir/file_shared b/molecule/apparmor/molecule.yml similarity index 100% rename from roles/deploy/tests/fixtures/app/dir/file_shared rename to molecule/apparmor/molecule.yml diff --git a/molecule/apt/converge.yml b/molecule/apt/converge.yml new file mode 100644 index 000000000..43d6df879 --- /dev/null +++ b/molecule/apt/converge.yml @@ -0,0 +1,539 @@ +--- + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/apt/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.apt + tasks_from: configs + vars: + manala_apt_configs_exclusive: false + manala_apt_configs_dir: "{{ tests_dir }}/default" + manala_apt_configs_defaults: {} + manala_apt_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.apt + tasks_from: configs + vars: + manala_apt_configs_exclusive: false + manala_apt_configs_dir: "{{ tests_dir }}/defaults" + manala_apt_configs_defaults: + template: fixtures/template.j2 + manala_apt_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.apt + tasks_from: configs + vars: + manala_apt_configs_exclusive: true + manala_apt_configs_dir: "{{ tests_dir }}/exclusive" + manala_apt_configs_defaults: {} + manala_apt_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" + +################ +# Sources List # +################ + +- name: Sources List + tags: [sources_list] + hosts: debian + vars: + tests_dir: /molecule/apt/sources_list + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Content + import_role: + name: manala.roles.apt + tasks_from: sources_list + vars: + manala_apt_sources_list_file: "{{ tests_dir }}/content" + manala_apt_sources_list_template: ~ + manala_apt_sources_list: | + Content + - name: Role - Template + import_role: + name: manala.roles.apt + tasks_from: sources_list + vars: + manala_apt_sources_list_file: "{{ tests_dir }}/template" + manala_apt_sources_list_template: fixtures/template.j2 + manala_apt_sources_list: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/sources_list.yml.j2') }}" + +############### +# Preferences # +############### + +- name: Preferences + tags: [preferences] + hosts: debian + vars: + tests_dir: /molecule/apt/preferences + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.apt + tasks_from: preferences + vars: + manala_apt_preferences_exclusive: false + manala_apt_preferences_dir: "{{ tests_dir }}/default" + manala_apt_preferences_defaults: {} + manala_apt_preferences: + # Short syntax + - git@backports + - libssl1.0.0@backports + - php@sury_php:300 + - sury_php:100 + - sury_php:200 + # Pattern syntax + - preference: ansible@ansible + - preference: ansible@ansible + file: ansible_foo + - preference: ansible@ansible + file: ansible_bar + package: foo bar* + - preference: ansible@ansible + file: ansible_baz + pin: baz + - preference: ansible@ansible + file: ansible_qux + priority: 1234 + # Verbose syntax + - package: foo + pin: foo + priority: 100 + file: foo_foo + # Template + - file: template + template: fixtures/template.j2 + # Flatten + - + - package: foo + pin: foo + priority: 100 + file: flatten + # State + - package: foo + pin: foo + priority: 100 + file: state_present_implicit + - package: foo + pin: foo + priority: 100 + file: state_present + state: present + - package: foo + pin: foo + priority: 100 + file: state_absent + state: absent + - package: foo + pin: foo + priority: 100 + file: state_absent_existing + state: absent + - package: foo + pin: foo + priority: 100 + file: state_ignore + state: ignore + - package: foo + pin: foo + priority: 100 + file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.apt + tasks_from: preferences + vars: + manala_apt_preferences_exclusive: false + manala_apt_preferences_dir: "{{ tests_dir }}/defaults" + manala_apt_preferences_defaults: + template: fixtures/template.j2 + manala_apt_preferences: + - file: template + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.apt + tasks_from: preferences + vars: + manala_apt_preferences_exclusive: true + manala_apt_preferences_dir: "{{ tests_dir }}/exclusive" + manala_apt_preferences_defaults: {} + manala_apt_preferences: + - package: bar + pin: bar + priority: 100 + file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/preferences.yml.j2') }}" + +######## +# Keys # +######## + +- name: Keys + tags: [keys] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.apt + tasks_from: keys + vars: + manala_apt_preferences: + - sury_php:100 + manala_apt_repositories: + - nginx + - source: deb https://dl.yarnpkg.com/debian/ stable main + key: yarn + - source: deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main + key: + url: https://www.postgresql.org/media/keys/ACCC4CF8.asc + id: ACCC4CF8 + manala_apt_keys: + # Short syntax + - sensu-go + # Verbose syntax + - url: http://www.rabbitmq.com/rabbitmq-signing-key-public.asc + id: 056E8E56 + - keyserver: keyserver.ubuntu.com + id: BC19DDBA # Galera + # Flatten + - + - multimedia + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/keys.yml.j2') }}" + +################ +# Repositories # +################ + +- name: Repositories - Default + tags: [repositories, repositories.default] + hosts: debian + tasks: + - name: Apt keys + apt_key: + url: "{{ item.0 }}" + id: "{{ item.1 }}" + loop: + - [http://deb.nodesource.com/gpgkey/nodesource.gpg.key, 68576280] + - name: Apt repositories + apt_repository: + repo: "{{ item }}" + loop: + - deb https://deb.nodesource.com/node_12.x {{ ansible_distribution_release }} main + - deb https://deb.nodesource.com/node_15.x {{ ansible_distribution_release }} main + - block: + - name: Role + import_role: + # Play role fully, because of "keys" tasks dependency + name: manala.roles.apt + vars: + manala_apt_preferences: + - sury_php:100 + manala_apt_repositories: + # Short syntax + - percona + # Pattern syntax + - repository: grafana + # Verbose syntax + - source: deb https://dl.yarnpkg.com/debian/ stable main + key: yarn + - source: deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main + key: + url: https://www.postgresql.org/media/keys/ACCC4CF8.asc + id: ACCC4CF8 + # Flatten + - + - nginx + # State + - source: deb https://deb.nodesource.com/node_10.x {{ ansible_distribution_release }} main + - source: deb https://deb.nodesource.com/node_12.x {{ ansible_distribution_release }} main + state: absent + - source: deb https://deb.nodesource.com/node_14.x {{ ansible_distribution_release }} main + state: present + - source: deb https://deb.nodesource.com/node_15.x {{ ansible_distribution_release }} main + state: ignore + - source: deb https://deb.nodesource.com/node_16.x {{ ansible_distribution_release }} main + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/repositories.default.yml.j2') }}" + +- name: Repositories - Exclusive + tags: [repositories, repositories.exclusive] + hosts: debian + tasks: + - name: Apt keys + apt_key: + url: "{{ item.0 }}" + id: "{{ item.1 }}" + loop: + - [http://deb.nodesource.com/gpgkey/nodesource.gpg.key, 68576280] + - name: Apt repositories + apt_repository: + repo: "{{ item }}" + loop: + - deb https://deb.nodesource.com/node_10.x {{ ansible_distribution_release }} main + - deb https://deb.nodesource.com/node_12.x {{ ansible_distribution_release }} main + - deb https://deb.nodesource.com/node_14.x {{ ansible_distribution_release }} main + - deb https://deb.nodesource.com/node_15.x {{ ansible_distribution_release }} main + - block: + - name: Role + import_role: + # Play role fully, because of "keys" tasks dependency + name: manala.roles.apt + tasks_from: repositories + vars: + manala_apt_repositories_exclusive: true + manala_apt_repositories: + - source: deb https://deb.nodesource.com/node_12.x {{ ansible_distribution_release }} main + - source: deb https://deb.nodesource.com/node_15.x {{ ansible_distribution_release }} main + state: ignore + - source: deb https://deb.nodesource.com/node_16.x {{ ansible_distribution_release }} main + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/repositories.exclusive.yml.j2') }}" + +############ +# Packages # +############ + +- name: Packages + tags: [packages] + hosts: debian + tasks: + - name: Packages absent + apt: + name: [asciijump, freesweep, wordplay] + state: absent + - name: Packages + apt: + name: [an, nettoe] + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - name: Packages apt + apt: + deb: http://snapshot.debian.org/archive/debian-archive/20120328T092752Z/debian/pool/main/p/pscan/pscan_1.2-9_amd64.deb + - block: + - name: Role + import_role: + name: manala.roles.apt + tasks_from: packages + vars: + manala_apt_packages: + # Short syntax + - asciijump + - http://snapshot.debian.org/archive/debian/20111228T033508Z/pool/main/s/spinner/spinner_1.2.4-3_amd64.deb + # Verbose syntax + - package: freesweep + # Flatten + - + - package: http://snapshot.debian.org/archive/debian/20160619T164515Z/pool/main/w/wait-for-it/wait-for-it_0.0~git20160501-1_all.deb + # State + - package: an + state: absent + - package: pscan + state: absent + - package: nettoe + state: ignore + - package: wordplay + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/packages.yml.j2') }}" + +######### +# Holds # +######### + +- name: Holds - Default + tags: [holds, holds.default] + hosts: debian + tasks: + - name: Dpkg selections install + dpkg_selections: + name: "{{ item }}" + selection: install + loop: [apt, python3, grep] + - name: Dpkg selections holds + dpkg_selections: + name: "{{ item }}" + selection: hold + loop: [dpkg, tar] + - block: + - name: Role + import_role: + name: manala.roles.apt + tasks_from: holds + vars: + manala_apt_holds: + # Short syntax + - apt + # Flatten + - + # State + - package: dpkg + state: absent + - package: python3 + state: present + - package: grep + state: ignore + - package: tar + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/holds.default.yml.j2') }}" + +- name: Holds - Exclusive + tags: [holds, holds.exclusive] + hosts: debian + tasks: + - name: Dpkg selections holds + dpkg_selections: + name: "{{ item }}" + selection: hold + loop: [python3, tar] + - block: + - name: Role + import_role: + name: manala.roles.apt + tasks_from: holds + vars: + manala_apt_holds_exclusive: true + manala_apt_holds: + - package: dpkg + - package: grep + state: ignore + - package: tar + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/holds.exclusive.yml.j2') }}" +########## +# Update # +########## + +- name: Update + tags: [update] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.apt + tasks_from: update + vars: + manala_apt: + update: true diff --git a/molecule/apt/fixtures/template.j2 b/molecule/apt/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/apt/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/apt/fixtures/template_file.j2 b/molecule/apt/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/apt/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/apt/goss/configs.yml.j2 b/molecule/apt/goss/configs.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/apt/goss/configs.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/apt/goss/holds.default.yml.j2 b/molecule/apt/goss/holds.default.yml.j2 new file mode 100644 index 000000000..4ccec6f3a --- /dev/null +++ b/molecule/apt/goss/holds.default.yml.j2 @@ -0,0 +1,13 @@ +--- + +command: + apt-mark showhold: + exit-status: 0 + stdout: + # Short syntax + - apt + # State + - "!dpkg" + - python3 + - "!grep" + - tar diff --git a/molecule/apt/goss/holds.exclusive.yml.j2 b/molecule/apt/goss/holds.exclusive.yml.j2 new file mode 100644 index 000000000..54c5d75fa --- /dev/null +++ b/molecule/apt/goss/holds.exclusive.yml.j2 @@ -0,0 +1,11 @@ +--- + +command: + apt-mark showhold: + exit-status: 0 + stdout: + - "!apt" + - dpkg + - "!python3" + - "!grep" + - "!tar" diff --git a/molecule/apt/goss/keys.yml.j2 b/molecule/apt/goss/keys.yml.j2 new file mode 100644 index 000000000..066696fe0 --- /dev/null +++ b/molecule/apt/goss/keys.yml.j2 @@ -0,0 +1,15 @@ +--- + +command: + + "apt-key adv --list-public-keys --with-colons | grep '^pub' | cut -d':' -f 5 | egrep -o '.{8}$'": + exit-status: 0 + stdout: + - 95BD4743 # Sury_php + - 7BD9BF62 # Nginx + - 86E50310 # Yarn + - ACCC4CF8 # PostgreSQL + - 0A3F7426 # Sensu Go + - 056E8E56 # RabbitMQ + - BC19DDBA # Galera + - 65558117 # Multimedia diff --git a/molecule/apt/goss/packages.yml.j2 b/molecule/apt/goss/packages.yml.j2 new file mode 100644 index 000000000..2c0561ce7 --- /dev/null +++ b/molecule/apt/goss/packages.yml.j2 @@ -0,0 +1,25 @@ +--- + +package: + # Short syntax + asciijump: + installed: true + spinner: + installed: true + versions: + - 1.2.4-3 + # Verbose syntax + freesweep: + installed: true + # Flatten + wait-for-it: + installed: true + # State + an: + installed: false + pscan: + installed: false + nettoe: + installed: true + wordplay: + installed: false diff --git a/molecule/apt/goss/preferences.yml.j2 b/molecule/apt/goss/preferences.yml.j2 new file mode 100644 index 000000000..da164271e --- /dev/null +++ b/molecule/apt/goss/preferences.yml.j2 @@ -0,0 +1,181 @@ +--- + +file: + + # Default - Short syntax + {{ tests_dir }}/default/git: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "Package: git git-*" + - "Pin: release a={{ ansible_distribution_release }}-backports" + - "Pin-Priority: 1000" + {{ tests_dir }}/default/libssl1_0_0: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "Package: libssl1.0.0" + - "Pin: release a={{ ansible_distribution_release }}-backports" + - "Pin-Priority: 1000" + {{ tests_dir }}/default/php: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "Package: php php-* /^php[1-9]+/" + - "Pin: origin packages.sury.org" + - "Pin-Priority: 300" + {{ tests_dir }}/default/sury_php: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "Package: *" + - "Pin: origin packages.sury.org" + - "Pin-Priority: 200" + # Default - Pattern syntax + {{ tests_dir }}/default/ansible: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "Package: ansible*" + - "Pin: origin ppa.launchpad.net" + - "Pin-Priority: 1000" + {{ tests_dir }}/default/ansible_foo: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "Package: ansible*" + - "Pin: origin ppa.launchpad.net" + - "Pin-Priority: 1000" + {{ tests_dir }}/default/ansible_bar: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "Package: foo bar" + - "Pin: origin ppa.launchpad.net" + - "Pin-Priority: 1000" + {{ tests_dir }}/default/ansible_baz: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "Package: ansible*" + - "Pin: baz" + - "Pin-Priority: 1000" + {{ tests_dir }}/default/ansible_qux: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "Package: ansible*" + - "Pin: origin ppa.launchpad.net" + - "Pin-Priority: 1234" + # Default - Verbose syntax + {{ tests_dir }}/default/foo_foo: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "Package: foo" + - "Pin: foo" + - "Pin-Priority: 100" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "Package: foo" + - "Pin: foo" + - "Pin-Priority: 100" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/apt/goss/repositories.default.yml.j2 b/molecule/apt/goss/repositories.default.yml.j2 new file mode 100644 index 000000000..125e4f2e1 --- /dev/null +++ b/molecule/apt/goss/repositories.default.yml.j2 @@ -0,0 +1,85 @@ +--- + +file: + # From preferences + /etc/apt/sources.list.d/packages_sury_org_php.list: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main" + # Short syntax + /etc/apt/sources.list.d/repo_percona_com_apt.list: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "deb http://repo.percona.com/apt {{ ansible_distribution_release }} main" + # Pattern syntax + /etc/apt/sources.list.d/packages_grafana_com_oss_deb.list: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "deb https://packages.grafana.com/oss/deb stable main" + # Verbose syntax + /etc/apt/sources.list.d/dl_yarnpkg_com_debian.list: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "deb https://dl.yarnpkg.com/debian/ stable main" + /etc/apt/sources.list.d/apt_postgresql_org_pub_repos_apt.list: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main" + # Flatten + /etc/apt/sources.list.d/nginx_org_packages_debian.list: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "deb http://nginx.org/packages/debian/ {{ ansible_distribution_release }} nginx" + # State + /etc/apt/sources.list.d/deb_nodesource_com_node_10_x.list: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "deb https://deb.nodesource.com/node_10.x {{ ansible_distribution_release }} main" + /etc/apt/sources.list.d/deb_nodesource_com_node_12_x.list: + exists: false + /etc/apt/sources.list.d/deb_nodesource_com_node_14_x.list: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "deb https://deb.nodesource.com/node_14.x {{ ansible_distribution_release }} main" + /etc/apt/sources.list.d/deb_nodesource_com_node_15_x.list: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "deb https://deb.nodesource.com/node_15.x {{ ansible_distribution_release }} main" + /etc/apt/sources.list.d/deb_nodesource_com_node_16_x.list: + exists: false diff --git a/molecule/apt/goss/repositories.exclusive.yml.j2 b/molecule/apt/goss/repositories.exclusive.yml.j2 new file mode 100644 index 000000000..0159c65e2 --- /dev/null +++ b/molecule/apt/goss/repositories.exclusive.yml.j2 @@ -0,0 +1,19 @@ +--- + +file: + /etc/apt/sources.list.d/deb_nodesource_com_node_10_x.list: + exists: false + /etc/apt/sources.list.d/deb_nodesource_com_node_12_x.list: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "deb https://deb.nodesource.com/node_12.x {{ ansible_distribution_release }} main" + /etc/apt/sources.list.d/deb_nodesource_com_node_14_x.list: + exists: false + /etc/apt/sources.list.d/deb_nodesource_com_node_15_x.list: + exists: false + /etc/apt/sources.list.d/deb_nodesource_com_node_16_x.list: + exists: false diff --git a/molecule/apt/goss/sources_list.yml.j2 b/molecule/apt/goss/sources_list.yml.j2 new file mode 100644 index 000000000..08d69cd5f --- /dev/null +++ b/molecule/apt/goss/sources_list.yml.j2 @@ -0,0 +1,22 @@ +--- + +file: + + # Content + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Template + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/roles/deploy/tests/fixtures/app/dir_shared/file b/molecule/apt/molecule.yml similarity index 100% rename from roles/deploy/tests/fixtures/app/dir_shared/file rename to molecule/apt/molecule.yml diff --git a/molecule/aptly/converge.yml b/molecule/aptly/converge.yml new file mode 100644 index 000000000..362578f1a --- /dev/null +++ b/molecule/aptly/converge.yml @@ -0,0 +1,111 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.aptly + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/aptly/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.aptly + vars: + manala_aptly_config_file: "{{ tests_dir }}/dict" + manala_aptly_config_template: ~ + manala_aptly_config: + rootDir: /molecule/aptly + architectures: + - amd64 + - name: Role - Content + import_role: + name: manala.roles.aptly + tasks_from: config + vars: + manala_aptly_config_file: "{{ tests_dir }}/content" + manala_aptly_config_template: ~ + manala_aptly_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.aptly + tasks_from: config + vars: + manala_aptly_config_file: "{{ tests_dir }}/template" + manala_aptly_config_template: fixtures/template.j2 + manala_aptly_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +################ +# Repositories # +################ + +- name: Repositories + tags: [repositories] + hosts: debian + vars: + tests_dir: /molecule/aptly/repositories + tasks: + - block: + - name: Role + import_role: + name: manala.roles.aptly + vars: + manala_aptly_config: + rootDir: "{{ tests_dir }}" + architectures: + - amd64 + manala_aptly_repositories: + - name: ignore + state: ignore + - name: foo + comment: Foo + component: main + distribution: stretch + origin: Foo + label: Foo + # Flatten + - + - name: bar + comment: Bar + component: main + distribution: buster + origin: Bar + label: Bar + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/repositories.yml.j2') }}" diff --git a/roles/aptly/tests/fixtures/gpg/private.asc b/molecule/aptly/fixtures/gpg/private.asc similarity index 100% rename from roles/aptly/tests/fixtures/gpg/private.asc rename to molecule/aptly/fixtures/gpg/private.asc diff --git a/molecule/aptly/fixtures/template.j2 b/molecule/aptly/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/aptly/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/aptly/goss/config.yml.j2 b/molecule/aptly/goss/config.yml.j2 new file mode 100644 index 000000000..5c1031129 --- /dev/null +++ b/molecule/aptly/goss/config.yml.j2 @@ -0,0 +1,32 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - '{' + - ' "architectures": [' + - ' "amd64"' + - ' ],' + - ' "rootDir": "/molecule/aptly"' + - '}' + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/roles/aptly/tests/0000_default.goss.yml b/molecule/aptly/goss/default.yml.j2 similarity index 100% rename from roles/aptly/tests/0000_default.goss.yml rename to molecule/aptly/goss/default.yml.j2 diff --git a/molecule/aptly/goss/repositories.yml.j2 b/molecule/aptly/goss/repositories.yml.j2 new file mode 100644 index 000000000..1e80b5101 --- /dev/null +++ b/molecule/aptly/goss/repositories.yml.j2 @@ -0,0 +1,41 @@ +--- + +command: + aptly repo list: + exit-status: 0 + timeout: 30000 + stdout: + - " * [bar]: Bar (packages: 0)" + - " * [foo]: Foo (packages: 0)" + aptly repo show foo: + exit-status: 0 + timeout: 30000 + stdout: + - "Name: foo" + - "Comment: Foo" + - "Default Distribution: stretch" + - "Default Component: main" + - "Number of packages: 0" + aptly repo show bar: + exit-status: 0 + timeout: 30000 + stdout: + - "Name: bar" + - "Comment: Bar" + - "Default Distribution: buster" + - "Default Component: main" + - "Number of packages: 0" + +file: + {{ tests_dir }}/public/dists/buster/Release: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/public/dists/buster/main/binary-amd64/Packages: + exists: true + filetype: file + owner: root + group: root + mode: "0644" diff --git a/roles/deploy/tests/fixtures/app/file b/molecule/aptly/molecule.yml similarity index 100% rename from roles/deploy/tests/fixtures/app/file rename to molecule/aptly/molecule.yml diff --git a/molecule/aptly/prepare.yml b/molecule/aptly/prepare.yml new file mode 100644 index 000000000..16623d930 --- /dev/null +++ b/molecule/aptly/prepare.yml @@ -0,0 +1,23 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - aptly@aptly + - name: Packages + apt: + name: [gnupg1] + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - name: Gpg key + command: + cmd: gpg1 --allow-secret-key-import --import + stdin: "{{ lookup('file', 'fixtures/gpg/private.asc') }}" + args: + creates: ~/.gnupg/trustdb.gpg diff --git a/molecule/backup_manager/converge.yml b/molecule/backup_manager/converge.yml new file mode 100644 index 000000000..33b3060ba --- /dev/null +++ b/molecule/backup_manager/converge.yml @@ -0,0 +1,128 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.backup_manager + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/backup_manager/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.backup_manager + tasks_from: configs + vars: + manala_backup_manager_configs_exclusive: false + manala_backup_manager_configs_dir: "{{ tests_dir }}/default" + manala_backup_manager_configs_defaults: {} + manala_backup_manager_configs: + # Dict + - file: dict + config: + BM_REPOSITORY_ROOT: /srv/backup/mysql + BM_TARBALL_DIRECTORIES: + - foo + - bar + # Flatten + - + - baz + BM_PIPE: + - COMMAND: command0 + NAME: name0 + FILETYPE: filetype0 + COMPRESS: compress0 + - COMMAND: command1 + NAME: name1 + FILETYPE: filetype1 + COMPRESS: compress1 + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.backup_manager + tasks_from: configs + vars: + manala_backup_manager_configs_exclusive: false + manala_backup_manager_configs_dir: "{{ tests_dir }}/defaults" + manala_backup_manager_configs_defaults: + template: fixtures/template.j2 + manala_backup_manager_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.backup_manager + tasks_from: configs + vars: + manala_backup_manager_configs_exclusive: true + manala_backup_manager_configs_dir: "{{ tests_dir }}/exclusive" + manala_backup_manager_configs_defaults: {} + manala_backup_manager_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" diff --git a/molecule/backup_manager/fixtures/template.j2 b/molecule/backup_manager/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/backup_manager/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/backup_manager/fixtures/template_file.j2 b/molecule/backup_manager/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/backup_manager/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/backup_manager/goss/configs.yml.j2 b/molecule/backup_manager/goss/configs.yml.j2 new file mode 100644 index 000000000..7ea9ff399 --- /dev/null +++ b/molecule/backup_manager/goss/configs.yml.j2 @@ -0,0 +1,117 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - export BM_REPOSITORY_ROOT="/srv/backup/mysql" + - export BM_TARBALL_DIRECTORIES="foo bar baz" + - BM_PIPE_COMMAND[0]="command0" + - BM_PIPE_NAME[0]="name0" + - BM_PIPE_FILETYPE[0]="filetype0" + - BM_PIPE_COMPRESS[0]="compress0" + - BM_PIPE_COMMAND[1]="command1" + - BM_PIPE_NAME[1]="name1" + - BM_PIPE_FILETYPE[1]="filetype1" + - BM_PIPE_COMPRESS[1]="compress1" + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/backup_manager/goss/default.yml.j2 b/molecule/backup_manager/goss/default.yml.j2 new file mode 100644 index 000000000..25df1bf82 --- /dev/null +++ b/molecule/backup_manager/goss/default.yml.j2 @@ -0,0 +1,15 @@ +--- + +package: + backup-manager: + installed: true + +command: + dpkg -s backup-manager: + exit-status: 0 + stdout: + - "/^Version: \\d+/" + backup-manager --version: + exit-status: 0 + stdout: + - Backup Manager diff --git a/roles/deploy/tests/fixtures/app/file_shared b/molecule/backup_manager/molecule.yml similarity index 100% rename from roles/deploy/tests/fixtures/app/file_shared rename to molecule/backup_manager/molecule.yml diff --git a/molecule/backup_manager/prepare.yml b/molecule/backup_manager/prepare.yml new file mode 100644 index 000000000..a1f723f2a --- /dev/null +++ b/molecule/backup_manager/prepare.yml @@ -0,0 +1,12 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - backup-manager@manala + when: ansible_distribution_release in ['stretch'] diff --git a/molecule/bind/converge.yml b/molecule/bind/converge.yml new file mode 100644 index 000000000..13745536e --- /dev/null +++ b/molecule/bind/converge.yml @@ -0,0 +1,202 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + vars: + tests_dir: /molecule/bind/default + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + name: manala.roles.bind + vars: + manala_bind_log_dir: "{{ tests_dir }}/log" + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Options # +########### + +- name: Options + tags: [options] + hosts: debian + vars: + tests_file: /molecule/bind/options + tasks: + - name: Clean tests file # noqa risky-file-permissions + file: + path: "{{ tests_file }}" + state: "{{ item }}" + loop: [absent, touch] + - block: + - name: Role + import_role: + name: manala.roles.bind + vars: + manala_bind_options_file: "{{ tests_file }}" + manala_bind_options: + - -u {{ manala_bind_user }} + - -4 # IPv4 only + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/options.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/bind/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [state_absent_existing] + - block: + - name: Role + import_role: + name: manala.roles.bind + vars: + manala_bind_configs_dir: "{{ tests_dir }}" + manala_bind_configs: + - file: template + template: fixtures/template.j2 + - file: content + content: | + Content + - file: state_absent_existing + state: absent + - file: omit + content: | + Omit + omit: true + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" + +######### +# Zones # +######### + +- name: Zones + tags: [zones] + hosts: debian + vars: + tests_dir: /molecule/bind/zones + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [db.state_absent_existing, db.dynamic_existing] + - block: + - name: Role + import_role: + name: manala.roles.bind + vars: + manala_bind_zones_dir: "{{ tests_dir }}" + manala_bind_zones: + - zone: template + template: fixtures/template.j2 + - zone: content + content: | + Content + - zone: state_absent_existing + state: absent + - zone: omit + content: | + Omit + omit: true + - zone: dynamic + content: | + Dynamic + dynamic: true + - zone: dynamic_existing + content: | + Dynamic existing + dynamic: true + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/zones.yml.j2') }}" + +################# +# Zones Records # +################# + +- name: Zones Records + tags: [zones_records] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.bind + vars: + manala_bind_configs: + - file: named.conf.local + content: | + zone "foo.local" { + type master; + file "{{ 'foo.local'|manala.roles.bind_zone_file }}"; + allow-update { 127.0.0.1; }; + }; + manala_bind_zones: + - zone: foo.local + dynamic: true + content: | + @ IN SOA ns.foo.local. contact.foo.local. ( + 1 ; serial + 604800 ; refresh (1 week) + 86400 ; retry (1 day) + 2419200 ; expire (4 weeks) + 86400 ; minimum (1 day) + ) + @ IN NS ns.foo.local. + ns IN A 172.16.1.1 + records: + - {record: bar, value: 172.16.1.123} + always: + - name: Packages + apt: + name: [bind9-host] + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/zones_records.yml.j2') }}" diff --git a/molecule/bind/fixtures/template.j2 b/molecule/bind/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/bind/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/bind/goss/configs.yml.j2 b/molecule/bind/goss/configs.yml.j2 new file mode 100644 index 000000000..e9c0a8e67 --- /dev/null +++ b/molecule/bind/goss/configs.yml.j2 @@ -0,0 +1,23 @@ +--- + +file: + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: bind + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: bind + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/state_absent_existing: + exists: false + {{ tests_dir }}/omit: + exists: false diff --git a/molecule/bind/goss/default.yml.j2 b/molecule/bind/goss/default.yml.j2 new file mode 100644 index 000000000..252d71b87 --- /dev/null +++ b/molecule/bind/goss/default.yml.j2 @@ -0,0 +1,13 @@ +--- + +package: + bind9: + installed: true + +file: + {{ tests_dir }}/log: + exists: true + filetype: directory + owner: bind + group: bind + mode: "0755" diff --git a/molecule/bind/goss/options.yml.j2 b/molecule/bind/goss/options.yml.j2 new file mode 100644 index 000000000..d38c367e1 --- /dev/null +++ b/molecule/bind/goss/options.yml.j2 @@ -0,0 +1,8 @@ +--- + +file: + {{ tests_file }}: + exists: true + filetype: file + contains: + - OPTIONS="-u bind -4" diff --git a/molecule/bind/goss/zones.yml.j2 b/molecule/bind/goss/zones.yml.j2 new file mode 100644 index 000000000..9e49af10e --- /dev/null +++ b/molecule/bind/goss/zones.yml.j2 @@ -0,0 +1,35 @@ +--- + +file: + {{ tests_dir }}/db.template: + exists: true + filetype: file + owner: bind + group: bind + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/db.content: + exists: true + filetype: file + owner: bind + group: bind + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/db.state_absent_existing: + exists: false + {{ tests_dir }}/db.omit: + exists: false + {{ tests_dir }}/db.dynamic: + exists: true + filetype: file + owner: bind + group: bind + mode: "0644" + contains: + - "/^Dynamic$/" + {{ tests_dir }}/db.dynamic_existing: + exists: true + contains: + - "!/^Dynamic existing$/" diff --git a/roles/bind/tests/0700_zones_records.goss.yml b/molecule/bind/goss/zones_records.yml.j2 similarity index 100% rename from roles/bind/tests/0700_zones_records.goss.yml rename to molecule/bind/goss/zones_records.yml.j2 diff --git a/roles/mount/tests/fixtures/bar b/molecule/bind/molecule.yml similarity index 100% rename from roles/mount/tests/fixtures/bar rename to molecule/bind/molecule.yml diff --git a/molecule/cloud_init/converge.yml b/molecule/cloud_init/converge.yml new file mode 100644 index 000000000..e23bee06b --- /dev/null +++ b/molecule/cloud_init/converge.yml @@ -0,0 +1,109 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.cloud_init + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/cloud_init/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.cloud_init + tasks_from: configs + vars: + manala_cloud_init_configs_exclusive: false + manala_cloud_init_configs_dir: "{{ tests_dir }}/default" + manala_cloud_init_configs_defaults: {} + manala_cloud_init_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.cloud_init + tasks_from: configs + vars: + manala_cloud_init_configs_exclusive: false + manala_cloud_init_configs_dir: "{{ tests_dir }}/defaults" + manala_cloud_init_configs_defaults: + template: fixtures/template.j2 + manala_cloud_init_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.cloud_init + tasks_from: configs + vars: + manala_cloud_init_configs_exclusive: true + manala_cloud_init_configs_dir: "{{ tests_dir }}/exclusive" + manala_cloud_init_configs_defaults: {} + manala_cloud_init_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" diff --git a/molecule/cloud_init/fixtures/template.j2 b/molecule/cloud_init/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/cloud_init/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/cloud_init/fixtures/template_file.j2 b/molecule/cloud_init/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/cloud_init/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/cloud_init/goss/configs.yml.j2 b/molecule/cloud_init/goss/configs.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/cloud_init/goss/configs.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/roles/cloud_init/tests/0100_install.goss.yml b/molecule/cloud_init/goss/default.yml.j2 similarity index 100% rename from roles/cloud_init/tests/0100_install.goss.yml rename to molecule/cloud_init/goss/default.yml.j2 diff --git a/molecule/cloud_init/molecule.yml b/molecule/cloud_init/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/composer/converge.yml b/molecule/composer/converge.yml new file mode 100644 index 000000000..71a3b3e38 --- /dev/null +++ b/molecule/composer/converge.yml @@ -0,0 +1,125 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.composer + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Version # +########### + +- name: Version + tags: [version] + hosts: debian + vars: + tests_dir: /molecule/composer/version + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Fixed + import_role: + name: manala.roles.composer + tasks_from: install + vars: + manala_composer_bin: "{{ tests_dir }}/fixed" + manala_composer_version: 1.8.0 + - name: Role - Update 1/2 + import_role: + name: manala.roles.composer + tasks_from: install + vars: + manala_composer_bin: "{{ tests_dir }}/update" + - name: Role - Update 2/2 + import_role: + name: manala.roles.composer + tasks_from: install + vars: + manala_composer_bin: "{{ tests_dir }}/update" + manala_composer_version: 1.10.15 + - name: Role - Major + import_role: + name: manala.roles.composer + tasks_from: install + vars: + manala_composer_bin: "{{ tests_dir }}/major" + manala_composer_version: 1 + - name: Role - Major Change 1/2 + import_role: + name: manala.roles.composer + tasks_from: install + vars: + manala_composer_bin: "{{ tests_dir }}/major_change" + manala_composer_version: 2.0.3 + - name: Role - Major Change 2/2 + import_role: + name: manala.roles.composer + tasks_from: install + vars: + manala_composer_bin: "{{ tests_dir }}/major_change" + manala_composer_version: 1 + - name: Role - Major No Change 1/2 + import_role: + name: manala.roles.composer + tasks_from: install + vars: + manala_composer_bin: "{{ tests_dir }}/major_no_change" + manala_composer_version: 1.10.15 + - name: Role - Major No Change 2/2 + import_role: + name: manala.roles.composer + tasks_from: install + vars: + manala_composer_bin: "{{ tests_dir }}/major_no_change" + manala_composer_version: 1 + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/version.yml.j2') }}" + +############## +# Users Auth # +############## + +- name: Users Auth + tags: [users_auth] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.composer + tasks_from: users_auth + vars: + manala_composer_users_auth: + - user: root + config: + github-oauth: + github.com: 9927d2878ffa105fc5236c762f2fd7zfd28b841d + http-basic: + repo.example1.org: + username: my-username1 + password: my-secret-password1 + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/users_auth.yml.j2') }}" diff --git a/molecule/composer/goss/default.yml.j2 b/molecule/composer/goss/default.yml.j2 new file mode 100644 index 000000000..e126b59f7 --- /dev/null +++ b/molecule/composer/goss/default.yml.j2 @@ -0,0 +1,29 @@ +--- + +package: + openssl: + installed: true + ca-certificates: + installed: true + unzip: + installed: true + +file: + {{ manala_composer_bin }}: + exists: true + filetype: file + owner: root +{% if ansible_distribution_release in ['stretch'] %} + group: staff +{% else %} + group: root +{% endif %} + mode: "0755" + /tmp/installer: + exists: false + +command: + {{ manala_composer_bin }} --version: + exit-status: 0 + stdout: + - Composer version diff --git a/roles/composer/tests/0200_users_auth.goss.yml b/molecule/composer/goss/users_auth.yml.j2 similarity index 100% rename from roles/composer/tests/0200_users_auth.goss.yml rename to molecule/composer/goss/users_auth.yml.j2 diff --git a/molecule/composer/goss/version.yml.j2 b/molecule/composer/goss/version.yml.j2 new file mode 100644 index 000000000..9af8a9445 --- /dev/null +++ b/molecule/composer/goss/version.yml.j2 @@ -0,0 +1,85 @@ +--- + +file: + # Fixed + {{ tests_dir }}/fixed: + exists: true + filetype: file + owner: root +{% if ansible_distribution_release in ['stretch'] %} + group: staff +{% else %} + group: root +{% endif %} + mode: "0755" + # Update + {{ tests_dir }}/update: + exists: true + filetype: file + owner: root +{% if ansible_distribution_release in ['stretch'] %} + group: staff +{% else %} + group: root +{% endif %} + mode: "0755" + # Major + {{ tests_dir }}/major: + exists: true + filetype: file + owner: root +{% if ansible_distribution_release in ['stretch'] %} + group: staff +{% else %} + group: root +{% endif %} + mode: "0755" + # Major Change + {{ tests_dir }}/major_change: + exists: true + filetype: file + owner: root +{% if ansible_distribution_release in ['stretch'] %} + group: staff +{% else %} + group: root +{% endif %} + mode: "0755" + # Major No Change + {{ tests_dir }}/major_no_change: + exists: true + filetype: file + owner: root +{% if ansible_distribution_release in ['stretch'] %} + group: staff +{% else %} + group: root +{% endif %} + mode: "0755" + +command: + # Fixed + {{ tests_dir }}/fixed --version: + exit-status: 0 + stdout: + - Composer version 1.8.0 + # Update + {{ tests_dir }}/update --version: + exit-status: 0 + stdout: + - Composer version 1.10.15 + # Major + {{ tests_dir }}/major --version: + exit-status: 0 + stdout: + - Composer version 1 + # Major Change + {{ tests_dir }}/major_change --version: + exit-status: 0 + stdout: + - Composer version 1 + # Major No Change + {{ tests_dir }}/major_no_change --version: + exit-status: 0 + stdout: + - Composer version 1.10.15 diff --git a/molecule/composer/molecule.yml b/molecule/composer/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/composer/prepare.yml b/molecule/composer/prepare.yml new file mode 100644 index 000000000..1c3794f4a --- /dev/null +++ b/molecule/composer/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Packages + apt: + name: [php-cli] + install_recommends: false + update_cache: true + cache_valid_time: 3600 diff --git a/molecule/cron/converge.yml b/molecule/cron/converge.yml new file mode 100644 index 000000000..523c60f0f --- /dev/null +++ b/molecule/cron/converge.yml @@ -0,0 +1,150 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.cron + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +######### +# Files # +######### + +- name: Files + tags: [files] + hosts: debian + vars: + tests_dir: /molecule/cron/files + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.cron + vars: + manala_cron_files_exclusive: false + manala_cron_files_dir: "{{ tests_dir }}/default" + manala_cron_files_defaults: {} + manala_cron_files: + # Dict + - file: dict + user: foo + env: + FOO: bar + jobs: + - command: cd /srv/app && bin/console app:bar:bar + user: bar + minute: 0 + hour: 7 + - command: cd /srv/app && bin/console app:baz:baz + minute: 1 + hour: 2 + day: 3 + month: 4 + weekday: 5 + - command: cd /srv/app && bin/console app:foo:present + state: present + - command: cd /srv/app && bin/console app:foo:absent + state: absent + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults - Template + import_role: + name: manala.roles.cron + tasks_from: files + vars: + manala_cron_files_exclusive: false + manala_cron_files_dir: "{{ tests_dir }}/defaults" + manala_cron_files_defaults: + template: fixtures/template.j2 + manala_cron_files: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Defaults - User + import_role: + name: manala.roles.cron + tasks_from: files + vars: + manala_cron_files_exclusive: false + manala_cron_files_dir: "{{ tests_dir }}/defaults" + manala_cron_files_defaults: + user: foo + manala_cron_files: + - file: user + jobs: + - command: foo + - file: user_file + user: bar + jobs: + - command: bar + - file: user_job + user: bar + jobs: + - command: baz + user: baz + - name: Role - Exclusive + import_role: + name: manala.roles.cron + tasks_from: files + vars: + manala_cron_files_exclusive: true + manala_cron_files_dir: "{{ tests_dir }}/exclusive" + manala_cron_files_defaults: {} + manala_cron_files: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/files.yml.j2') }}" diff --git a/molecule/cron/fixtures/template.j2 b/molecule/cron/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/cron/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/cron/fixtures/template_file.j2 b/molecule/cron/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/cron/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/roles/cron/tests/0000_default.goss.yml b/molecule/cron/goss/default.yml.j2 similarity index 100% rename from roles/cron/tests/0000_default.goss.yml rename to molecule/cron/goss/default.yml.j2 diff --git a/molecule/cron/goss/files.yml.j2 b/molecule/cron/goss/files.yml.j2 new file mode 100644 index 000000000..c630c8443 --- /dev/null +++ b/molecule/cron/goss/files.yml.j2 @@ -0,0 +1,137 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - 'FOO="bar"' + - "0 7 * * * bar cd /srv/app && bin/console app:bar:bar" + - "1 2 3 4 5 foo cd /srv/app && bin/console app:baz:baz" + - "* * * * * foo cd /srv/app && bin/console app:foo:present" + - "!* * * * * foo cd /srv/app && bin/console app:foo:absent" + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults - Template + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Defaults - User + {{ tests_dir }}/defaults/user: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "* * * * * foo foo" + {{ tests_dir }}/defaults/user_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "* * * * * bar bar" + {{ tests_dir }}/defaults/user_job: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "* * * * * baz baz" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/cron/molecule.yml b/molecule/cron/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/deploy/converge.yml b/molecule/deploy/converge.yml new file mode 100644 index 000000000..5c315e61f --- /dev/null +++ b/molecule/deploy/converge.yml @@ -0,0 +1,334 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + vars: + tests_dir: /molecule/deploy/default + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + name: manala.roles.deploy + vars: + manala_deploy_dir: "{{ tests_dir }}/app" + manala_deploy_strategy: synchronize + manala_deploy_strategy_synchronize_src: fixtures/app/ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +############ +# Strategy # +############ + +- name: Strategy + tags: [strategy] + hosts: debian + vars: + tests_dir: /molecule/deploy/strategy + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Synchronize + import_role: + name: manala.roles.deploy + vars: + manala_deploy_dir: "{{ tests_dir }}/synchronize" + manala_deploy_strategy: synchronize + manala_deploy_strategy_synchronize_src: fixtures/app/ + manala_deploy_strategy_include_name: ~ + manala_deploy_strategy_include_options: [] + - name: Role - Include + import_role: + name: manala.roles.deploy + vars: + manala_deploy_dir: "{{ tests_dir }}/include" + manala_deploy_strategy: include + manala_deploy_strategy_synchronize_src: ~ + manala_deploy_strategy_include_name: fixtures/strategy.yml + manala_deploy_strategy_include_options: + filename: file + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/strategy.yml.j2') }}" + +########## +# Shared # +########## + +- name: Shared + tags: [shared] + hosts: debian + vars: + tests_dir: /molecule/deploy/shared + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - name: Directories # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/app/{{ item }}" + state: directory + loop: [shared, shared/dir, shared/dir/dir] + - name: Files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/app/{{ item }}" + state: touch + loop: [shared/file_shared_existing, shared/dir/file_shared_existing, shared/dir/dir/file_shared_existing] + - name: Links # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/app/{{ item }}_link" + src: "{{ tests_dir }}/app/{{ item }}" + state: link + loop: [shared/file_shared_existing, shared/dir/file_shared_existing, shared/dir/dir/file_shared_existing] + - block: + - name: Role + import_role: + name: manala.roles.deploy + vars: + manala_deploy_dir: "{{ tests_dir }}/app" + manala_deploy_strategy: synchronize + manala_deploy_strategy_synchronize_src: fixtures/app/ + manala_deploy_shared_files: + - file_shared + - file_shared_existing + - file_shared_existing_link + - dir/file_shared + - dir/file_shared_existing + - dir/file_shared_existing_link + - dir/dir/file_shared + - dir/dir/file_shared_existing + - dir/dir/file_shared_existing_link + manala_deploy_shared_dirs: + - dir_shared + - dir/dir_shared + - dir/dir/dir_shared + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/shared.yml.j2') }}" + +########## +# Copied # +########## + +- name: Copied + tags: [copied] + hosts: debian + vars: + tests_dir: /molecule/deploy/copied + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/app/releases/20170520092302/vendor" + state: directory + - name: Link # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/app/current" + src: "{{ tests_dir }}/app/releases/20170520092302" + state: link + - block: + - name: Role + import_role: + name: manala.roles.deploy + vars: + manala_deploy_dir: "{{ tests_dir }}/app" + manala_deploy_strategy: synchronize + manala_deploy_strategy_synchronize_src: fixtures/app/ + manala_deploy_copied: + - vendor + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/copied.yml.j2') }}" + +############ +# Writable # +############ + +- name: Writable + tags: [writable] + hosts: debian + vars: + tests_dir: /molecule/deploy/writable + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + name: manala.roles.deploy + vars: + manala_deploy_dir: "{{ tests_dir }}/app" + manala_deploy_strategy: synchronize + manala_deploy_strategy_synchronize_src: fixtures/app/ + manala_deploy_writable_dirs_default: + mode: ugo=rwx + follow: true + recurse: true + manala_deploy_writable_dirs: + - dir + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/writable.yml.j2') }}" + +######### +# Tasks # +######### + +- name: Tasks + tags: [tasks] + hosts: debian + vars: + tests_dir: /molecule/deploy/tasks + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Raw + import_role: + name: manala.roles.deploy + vars: + manala_deploy_dir: "{{ tests_dir }}/raw" + manala_deploy_strategy: synchronize + manala_deploy_strategy_synchronize_src: fixtures/app/ + manala_deploy_tasks: + - raw: touch {{ tests_dir }}/raw/file + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/tasks.yml.j2') }}" + +########### +# Removed # +########### + +- name: Removed + tags: [removed] + hosts: debian + vars: + tests_dir: /molecule/deploy/removed + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + name: manala.roles.deploy + vars: + manala_deploy_dir: "{{ tests_dir }}/app" + manala_deploy_strategy: synchronize + manala_deploy_strategy_synchronize_src: fixtures/app/ + manala_deploy_removed: + - file + - dir + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/removed.yml.j2') }}" + +######### +# Clean # +######### + +- name: Clean + tags: [clean] + hosts: debian + vars: + tests_dir: /molecule/deploy/clean + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - name: Directories # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/app/releases/{{ item }}" + state: directory + loop: [20170520092302, 20170520092413, 20170520092714, 20170520092738, 20170520093012, 20170520093234] + - block: + - name: Role + import_role: + name: manala.roles.deploy + vars: + manala_deploy_dir: "{{ tests_dir }}/app" + manala_deploy_strategy: synchronize + manala_deploy_strategy_synchronize_src: fixtures/app/ + manala_deploy_releases: 2 + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/clean.yml.j2') }}" + +############## +# Post Tasks # +############## + +- name: Post Tasks + tags: [post_tasks] + hosts: debian + vars: + tests_dir: /molecule/deploy/post_tasks + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Raw + import_role: + name: manala.roles.deploy + vars: + manala_deploy_dir: "{{ tests_dir }}/raw" + manala_deploy_strategy: synchronize + manala_deploy_strategy_synchronize_src: fixtures/app/ + manala_deploy_tasks: + - raw: touch {{ tests_dir }}/raw/file + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/post_tasks.yml.j2') }}" diff --git a/molecule/deploy/fixtures/app/dir/dir/dir_shared/file b/molecule/deploy/fixtures/app/dir/dir/dir_shared/file new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/deploy/fixtures/app/dir/dir/file_shared b/molecule/deploy/fixtures/app/dir/dir/file_shared new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/deploy/fixtures/app/dir/dir_shared/file b/molecule/deploy/fixtures/app/dir/dir_shared/file new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/deploy/fixtures/app/dir/file b/molecule/deploy/fixtures/app/dir/file new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/deploy/fixtures/app/dir/file_shared b/molecule/deploy/fixtures/app/dir/file_shared new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/deploy/fixtures/app/dir_shared/file b/molecule/deploy/fixtures/app/dir_shared/file new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/deploy/fixtures/app/file b/molecule/deploy/fixtures/app/file new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/deploy/fixtures/app/file_shared b/molecule/deploy/fixtures/app/file_shared new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/deploy/fixtures/strategy.yml b/molecule/deploy/fixtures/strategy.yml new file mode 100644 index 000000000..cdeacce36 --- /dev/null +++ b/molecule/deploy/fixtures/strategy.yml @@ -0,0 +1,12 @@ +--- + +- block: + - name: strategy > Create release dir + file: + path: "{{ deploy_helper.new_release_path }}/" + state: directory + + - name: strategy > Touch file + file: + path: "{{ deploy_helper.new_release_path }}/{{ manala_deploy_strategy_include_options.filename }}" + state: touch diff --git a/molecule/deploy/goss/clean.yml.j2 b/molecule/deploy/goss/clean.yml.j2 new file mode 100644 index 000000000..766aab78e --- /dev/null +++ b/molecule/deploy/goss/clean.yml.j2 @@ -0,0 +1,7 @@ +--- + +command: + find {{ tests_dir }}/app/releases -mindepth 1 -maxdepth 1 -type d | wc -l: + exit-status: 0 + stdout: + - 3 diff --git a/molecule/deploy/goss/copied.yml.j2 b/molecule/deploy/goss/copied.yml.j2 new file mode 100644 index 000000000..4a98869d9 --- /dev/null +++ b/molecule/deploy/goss/copied.yml.j2 @@ -0,0 +1,6 @@ +--- + +file: + {{ tests_dir }}/app/current/vendor: + exists: true + filetype: directory diff --git a/molecule/deploy/goss/default.yml.j2 b/molecule/deploy/goss/default.yml.j2 new file mode 100644 index 000000000..11709532a --- /dev/null +++ b/molecule/deploy/goss/default.yml.j2 @@ -0,0 +1,19 @@ +--- + +file: + {{ tests_dir }}/app: + exists: true + filetype: directory + {{ tests_dir }}/app/releases: + exists: true + filetype: directory + {{ tests_dir }}/app/shared: + exists: true + filetype: directory + # Finalize + {{ tests_dir }}/app/current: + exists: true + filetype: symlink + # Unfinished + {{ tests_dir }}/app/current/{{ deploy_helper.unfinished_filename }}: + exists: false diff --git a/molecule/deploy/goss/post_tasks.yml.j2 b/molecule/deploy/goss/post_tasks.yml.j2 new file mode 100644 index 000000000..aad37d573 --- /dev/null +++ b/molecule/deploy/goss/post_tasks.yml.j2 @@ -0,0 +1,7 @@ +--- + +file: + # Raw + {{ tests_dir }}/raw/file: + exists: true + filetype: file diff --git a/molecule/deploy/goss/removed.yml.j2 b/molecule/deploy/goss/removed.yml.j2 new file mode 100644 index 000000000..f7850effb --- /dev/null +++ b/molecule/deploy/goss/removed.yml.j2 @@ -0,0 +1,14 @@ +--- + +file: + {{ tests_dir }}/app/current/file: + exists: false + {{ tests_dir }}/app/current/file_shared: + exists: true + filetype: file + + {{ tests_dir }}/app/current/dir: + exists: false + {{ tests_dir }}/app/current/dir_shared: + exists: true + filetype: directory diff --git a/molecule/deploy/goss/shared.yml.j2 b/molecule/deploy/goss/shared.yml.j2 new file mode 100644 index 000000000..6b979610a --- /dev/null +++ b/molecule/deploy/goss/shared.yml.j2 @@ -0,0 +1,101 @@ +--- + +file: + {{ tests_dir }}/app/shared/file_shared: + exists: true + filetype: file + {{ tests_dir }}/app/shared/file_shared_existing: + exists: true + filetype: file + {{ tests_dir }}/app/shared/file_shared_existing_link: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/app/shared/file_shared_existing + {{ tests_dir }}/app/current/file_shared: + exists: true + filetype: symlink + linked-to: ../../shared/file_shared + {{ tests_dir }}/app/current/file_shared_existing: + exists: true + filetype: symlink + linked-to: ../../shared/file_shared_existing + {{ tests_dir }}/app/current/file_shared_existing_link: + exists: true + filetype: symlink + linked-to: ../../shared/file_shared_existing_link + + {{ tests_dir }}/app/shared/dir: + exists: true + filetype: directory + {{ tests_dir }}/app/shared/dir/file_shared: + exists: true + filetype: file + {{ tests_dir }}/app/shared/dir/file_shared_existing: + exists: true + filetype: file + {{ tests_dir }}/app/shared/dir/file_shared_existing_link: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/app/shared/dir/file_shared_existing + {{ tests_dir }}/app/current/dir/file_shared: + exists: true + filetype: symlink + linked-to: ../../../shared/dir/file_shared + {{ tests_dir }}/app/current/dir/file_shared_existing: + exists: true + filetype: symlink + linked-to: ../../../shared/dir/file_shared_existing + {{ tests_dir }}/app/current/dir/file_shared_existing_link: + exists: true + filetype: symlink + linked-to: ../../../shared/dir/file_shared_existing_link + + {{ tests_dir }}/app/shared/dir/dir: + exists: true + filetype: directory + {{ tests_dir }}/app/shared/dir/dir/file_shared: + exists: true + filetype: file + {{ tests_dir }}/app/shared/dir/dir/file_shared_existing: + exists: true + filetype: file + {{ tests_dir }}/app/shared/dir/dir/file_shared_existing_link: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/app/shared/dir/dir/file_shared_existing + {{ tests_dir }}/app/current/dir/dir/file_shared: + exists: true + filetype: symlink + linked-to: ../../../../shared/dir/dir/file_shared + {{ tests_dir }}/app/current/dir/dir/file_shared_existing: + exists: true + filetype: symlink + linked-to: ../../../../shared/dir/dir/file_shared_existing + {{ tests_dir }}/app/current/dir/dir/file_shared_existing_link: + exists: true + filetype: symlink + linked-to: ../../../../shared/dir/dir/file_shared_existing_link + + {{ tests_dir }}/app/shared/dir_shared: + exists: true + filetype: directory + {{ tests_dir }}/app/current/dir_shared: + exists: true + filetype: symlink + linked-to: ../../shared/dir_shared + + {{ tests_dir }}/app/shared/dir/dir_shared: + exists: true + filetype: directory + {{ tests_dir }}/app/current/dir/dir_shared: + exists: true + filetype: symlink + linked-to: ../../../shared/dir/dir_shared + + {{ tests_dir }}/app/shared/dir/dir/dir_shared: + exists: true + filetype: directory + {{ tests_dir }}/app/current/dir/dir/dir_shared: + exists: true + filetype: symlink + linked-to: ../../../../shared/dir/dir/dir_shared diff --git a/molecule/deploy/goss/strategy.yml.j2 b/molecule/deploy/goss/strategy.yml.j2 new file mode 100644 index 000000000..f2ed51eaf --- /dev/null +++ b/molecule/deploy/goss/strategy.yml.j2 @@ -0,0 +1,47 @@ +--- + +file: + # Synchronize + {{ tests_dir }}/synchronize: + exists: true + filetype: directory + {{ tests_dir }}/synchronize/current: + exists: true + filetype: symlink + {{ tests_dir }}/synchronize/current/file: + exists: true + filetype: file + {{ tests_dir }}/synchronize/current/file_shared: + exists: true + filetype: file + {{ tests_dir }}/synchronize/current/dir: + exists: true + filetype: directory + {{ tests_dir }}/synchronize/current/dir/dir: + exists: true + filetype: directory + {{ tests_dir }}/synchronize/current/dir/dir_shared: + exists: true + filetype: directory + {{ tests_dir }}/synchronize/current/dir/file: + exists: true + filetype: file + {{ tests_dir }}/synchronize/current/dir/file_shared: + exists: true + filetype: file + {{ tests_dir }}/synchronize/current/dir_shared: + exists: true + filetype: directory + {{ tests_dir }}/synchronize/current/dir_shared/file: + exists: true + filetype: file + # Include + {{ tests_dir }}/include: + exists: true + filetype: directory + {{ tests_dir }}/include/current: + exists: true + filetype: symlink + {{ tests_dir }}/include/current/file: + exists: true + filetype: file diff --git a/molecule/deploy/goss/tasks.yml.j2 b/molecule/deploy/goss/tasks.yml.j2 new file mode 100644 index 000000000..aad37d573 --- /dev/null +++ b/molecule/deploy/goss/tasks.yml.j2 @@ -0,0 +1,7 @@ +--- + +file: + # Raw + {{ tests_dir }}/raw/file: + exists: true + filetype: file diff --git a/molecule/deploy/goss/writable.yml.j2 b/molecule/deploy/goss/writable.yml.j2 new file mode 100644 index 000000000..7ca8124ce --- /dev/null +++ b/molecule/deploy/goss/writable.yml.j2 @@ -0,0 +1,7 @@ +--- + +file: + {{ tests_dir }}/app/current/dir: + exists: true + filetype: directory + mode: "0777" diff --git a/molecule/deploy/molecule.yml b/molecule/deploy/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/deploy/prepare.yml b/molecule/deploy/prepare.yml new file mode 100644 index 000000000..ff734b6c0 --- /dev/null +++ b/molecule/deploy/prepare.yml @@ -0,0 +1,22 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Packages + apt: + name: [rsync] + install_recommends: false + update_cache: true + cache_valid_time: 3600 + +- hosts: 127.0.0.1 + connection: local + tags: [always] + tasks: + - name: Packages local + apt: + name: [rsync] + install_recommends: false + update_cache: true + cache_valid_time: 3600 diff --git a/molecule/dhcp/converge.yml b/molecule/dhcp/converge.yml new file mode 100644 index 000000000..8370efa42 --- /dev/null +++ b/molecule/dhcp/converge.yml @@ -0,0 +1,25 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.dhcp + vars: + manala_dhcp_interfaces: + - "{{ ansible_default_ipv4.interface }}" + manala_dhcp_config_content: | + subnet {{ ansible_default_ipv4.network }} netmask {{ ansible_default_ipv4.netmask }} { + } + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/dhcp/goss/default.yml.j2 b/molecule/dhcp/goss/default.yml.j2 new file mode 100644 index 000000000..63801b258 --- /dev/null +++ b/molecule/dhcp/goss/default.yml.j2 @@ -0,0 +1,38 @@ +--- + +package: + isc-dhcp-server: + installed: true + +service: + isc-dhcp-server: + enabled: true + running: true + +file: + # Interfaces + {{ manala_dhcp_interfaces_file }}: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - INTERFACESv4="{{ ansible_default_ipv4.interface }}" + # Config + {{ manala_dhcp_config_file }}: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "subnet {{ ansible_default_ipv4.network }} netmask {{ ansible_default_ipv4.netmask }} {" + - "}" + +command: + # Interfaces + ps aux: + exit-status: 0 + stdout: + - /usr/sbin/dhcpd -4 -q -cf {{ manala_dhcp_config_file }} {{ ansible_default_ipv4.interface }} diff --git a/molecule/dhcp/molecule.yml b/molecule/dhcp/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/dnsmasq/converge.yml b/molecule/dnsmasq/converge.yml new file mode 100644 index 000000000..034b66c14 --- /dev/null +++ b/molecule/dnsmasq/converge.yml @@ -0,0 +1,109 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.dnsmasq + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/dnsmasq/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.dnsmasq + vars: + manala_dnsmasq_configs_exclusive: false + manala_dnsmasq_configs_dir: "{{ tests_dir }}/default" + manala_dnsmasq_configs_defaults: {} + manala_dnsmasq_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.dnsmasq + tasks_from: configs + vars: + manala_dnsmasq_configs_exclusive: false + manala_dnsmasq_configs_dir: "{{ tests_dir }}/defaults" + manala_dnsmasq_configs_defaults: + template: fixtures/template.j2 + manala_dnsmasq_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.dnsmasq + tasks_from: configs + vars: + manala_dnsmasq_configs_exclusive: true + manala_dnsmasq_configs_dir: "{{ tests_dir }}/exclusive" + manala_dnsmasq_configs_defaults: {} + manala_dnsmasq_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" diff --git a/molecule/dnsmasq/fixtures/template.j2 b/molecule/dnsmasq/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/dnsmasq/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/dnsmasq/fixtures/template_file.j2 b/molecule/dnsmasq/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/dnsmasq/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/dnsmasq/goss/configs.yml.j2 b/molecule/dnsmasq/goss/configs.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/dnsmasq/goss/configs.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/dnsmasq/goss/default.yml.j2 b/molecule/dnsmasq/goss/default.yml.j2 new file mode 100644 index 000000000..e9c8265f7 --- /dev/null +++ b/molecule/dnsmasq/goss/default.yml.j2 @@ -0,0 +1,10 @@ +--- + +package: + dnsmasq: + installed: true + +service: + dnsmasq: + enabled: true + running: true diff --git a/molecule/dnsmasq/molecule.yml b/molecule/dnsmasq/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/docker/converge.yml b/molecule/docker/converge.yml new file mode 100644 index 000000000..bf70058d2 --- /dev/null +++ b/molecule/docker/converge.yml @@ -0,0 +1,164 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.docker + vars: + manala_docker_config_daemon: + storage-driver: vfs + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +################# +# Config Daemon # +################# + +- name: Config Daemon + tags: [config_daemon] + hosts: debian + vars: + tests_dir: /molecule/docker/config_daemon + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.docker + vars: + manala_docker_config_daemon: + storage-driver: vfs + - name: Role - Dict + import_role: + name: manala.roles.docker + tasks_from: config_daemon + vars: + manala_docker_config_daemon_file: "{{ tests_dir }}/dict" + manala_docker_config_daemon_template: ~ + manala_docker_config_daemon: + storage-driver: vfs + experimental: false + - name: Role - Content + import_role: + name: manala.roles.docker + tasks_from: config_daemon + vars: + manala_docker_config_daemon_file: "{{ tests_dir }}/content" + manala_docker_config_daemon_template: ~ + manala_docker_config_daemon: | + Content + - name: Role - Template + import_role: + name: manala.roles.docker + tasks_from: config_daemon + vars: + manala_docker_config_daemon_file: "{{ tests_dir }}/template" + manala_docker_config_daemon_template: fixtures/template.j2 + manala_docker_config_daemon: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config_daemon.yml.j2') }}" + +################ +# Applications # +################ + +- name: Applications + tags: [applications] + hosts: debian + vars: + tests_dir: /molecule/docker/applications + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + name: manala.roles.docker + vars: + manala_docker_config_daemon: + storage-driver: vfs + manala_docker_applications_dir: "{{ tests_dir }}" + manala_docker_applications: + - hello-world + - application: npm + image: node + command: npm + tag: alpine + - application: template + template: fixtures/template.j2 + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/applications.yml.j2') }}" + +############## +# Containers # +############## + +- name: Containers + tags: [containers] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.docker + vars: + manala_docker_config_daemon: + storage-driver: vfs + manala_docker_containers: + - name: hello-world + image: hello-world + - name: busybox + image: busybox + state: ignore + # Flatten + - + - name: alpine + image: alpine + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/containers.yml.j2') }}" + +########## +# Update # +########## + +- name: Update + tags: [update] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.docker + vars: + manala_docker_config_daemon: + storage-driver: vfs + manala_docker: + update: true diff --git a/molecule/docker/fixtures/template.j2 b/molecule/docker/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/docker/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/docker/goss/applications.yml.j2 b/molecule/docker/goss/applications.yml.j2 new file mode 100644 index 000000000..162088053 --- /dev/null +++ b/molecule/docker/goss/applications.yml.j2 @@ -0,0 +1,33 @@ +--- + +file: + {{ tests_dir }}/hello-world: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + {{ tests_dir }}/npm: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + contains: + - "/^Template$/" + +command: + {{ tests_dir }}/hello-world: + exit-status: 0 + timeout: 60000 + stdout: + - Hello from Docker! + {{ tests_dir }}/npm --version: + exit-status: 0 + timeout: 60000 diff --git a/molecule/docker/goss/config_daemon.yml.j2 b/molecule/docker/goss/config_daemon.yml.j2 new file mode 100644 index 000000000..84378d500 --- /dev/null +++ b/molecule/docker/goss/config_daemon.yml.j2 @@ -0,0 +1,30 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "{" + - " \"experimental\": false," + - " \"storage-driver\": \"vfs\"" + - "}" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/roles/docker/tests/0500_containers.goss.yml b/molecule/docker/goss/containers.yml.j2 similarity index 100% rename from roles/docker/tests/0500_containers.goss.yml rename to molecule/docker/goss/containers.yml.j2 diff --git a/roles/docker/tests/0000_default.goss.yml b/molecule/docker/goss/default.yml.j2 similarity index 100% rename from roles/docker/tests/0000_default.goss.yml rename to molecule/docker/goss/default.yml.j2 diff --git a/molecule/docker/molecule.yml b/molecule/docker/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/docker/prepare.yml b/molecule/docker/prepare.yml new file mode 100644 index 000000000..f30217d3f --- /dev/null +++ b/molecule/docker/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - docker@docker diff --git a/molecule/elasticsearch.2/converge.yml b/molecule/elasticsearch.2/converge.yml new file mode 100644 index 000000000..9d63d0dda --- /dev/null +++ b/molecule/elasticsearch.2/converge.yml @@ -0,0 +1,30 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + tasks: + - block: + - name: Role + import_role: + name: manala.roles.elasticsearch + vars: + manala_elasticsearch_plugins: + - mobz/elasticsearch-head + always: + - name: Wait for pretty response + uri: + url: http://localhost:9200/?pretty + register: result + until: result.status == 200 + retries: 60 + delay: 1 + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/elasticsearch/tests/0001_default.2.goss.yml b/molecule/elasticsearch.2/goss/default.yml.j2 similarity index 100% rename from roles/elasticsearch/tests/0001_default.2.goss.yml rename to molecule/elasticsearch.2/goss/default.yml.j2 diff --git a/molecule/elasticsearch.2/molecule.yml b/molecule/elasticsearch.2/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/elasticsearch.2/prepare.yml b/molecule/elasticsearch.2/prepare.yml new file mode 100644 index 000000000..0eb64459d --- /dev/null +++ b/molecule/elasticsearch.2/prepare.yml @@ -0,0 +1,15 @@ +--- + +- hosts: + - debian.stretch + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - elasticsearch@elasticsearch_2 + - name: Java + import_role: + name: manala.roles.java diff --git a/molecule/elasticsearch.5/converge.yml b/molecule/elasticsearch.5/converge.yml new file mode 100644 index 000000000..a30038dff --- /dev/null +++ b/molecule/elasticsearch.5/converge.yml @@ -0,0 +1,32 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.elasticsearch + vars: + manala_elasticsearch_environment_template: environment/elasticsearch/elasticsearch.j2 + manala_elasticsearch_environment: + ES_JAVA_OPTS: -Xms256m -Xmx256m + manala_elasticsearch_plugins: + - analysis-icu + always: + - name: Wait for pretty response + uri: + url: http://localhost:9200/?pretty + register: result + until: result.status == 200 + retries: 60 + delay: 1 + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/elasticsearch/tests/0002_default.5.goss.yml b/molecule/elasticsearch.5/goss/default.yml.j2 similarity index 100% rename from roles/elasticsearch/tests/0002_default.5.goss.yml rename to molecule/elasticsearch.5/goss/default.yml.j2 diff --git a/molecule/elasticsearch.5/molecule.yml b/molecule/elasticsearch.5/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/elasticsearch.5/prepare.yml b/molecule/elasticsearch.5/prepare.yml new file mode 100644 index 000000000..86c77c422 --- /dev/null +++ b/molecule/elasticsearch.5/prepare.yml @@ -0,0 +1,13 @@ +--- +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - elasticsearch@elasticsearch_5 + - name: Java + import_role: + name: manala.roles.java diff --git a/molecule/elasticsearch.6/converge.yml b/molecule/elasticsearch.6/converge.yml new file mode 100644 index 000000000..a30038dff --- /dev/null +++ b/molecule/elasticsearch.6/converge.yml @@ -0,0 +1,32 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.elasticsearch + vars: + manala_elasticsearch_environment_template: environment/elasticsearch/elasticsearch.j2 + manala_elasticsearch_environment: + ES_JAVA_OPTS: -Xms256m -Xmx256m + manala_elasticsearch_plugins: + - analysis-icu + always: + - name: Wait for pretty response + uri: + url: http://localhost:9200/?pretty + register: result + until: result.status == 200 + retries: 60 + delay: 1 + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/elasticsearch/tests/0003_default.6.goss.yml b/molecule/elasticsearch.6/goss/default.yml.j2 similarity index 100% rename from roles/elasticsearch/tests/0003_default.6.goss.yml rename to molecule/elasticsearch.6/goss/default.yml.j2 diff --git a/molecule/elasticsearch.6/molecule.yml b/molecule/elasticsearch.6/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/elasticsearch.6/prepare.yml b/molecule/elasticsearch.6/prepare.yml new file mode 100644 index 000000000..339b8a294 --- /dev/null +++ b/molecule/elasticsearch.6/prepare.yml @@ -0,0 +1,13 @@ +--- +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - elasticsearch@elasticsearch_6 + - name: Java + import_role: + name: manala.roles.java diff --git a/molecule/elasticsearch.7/converge.yml b/molecule/elasticsearch.7/converge.yml new file mode 100644 index 000000000..fa183b351 --- /dev/null +++ b/molecule/elasticsearch.7/converge.yml @@ -0,0 +1,164 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.elasticsearch + vars: + manala_elasticsearch_environment_template: environment/elasticsearch/elasticsearch.j2 + manala_elasticsearch_environment: + # See: https://github.com/elastic/elasticsearch/issues/57018#issuecomment-694703398 + ES_JAVA_OPTS: -Xms256m -Xmx256m -Djava.io.tmpdir=/var/log/elasticsearch + manala_elasticsearch_plugins: + - analysis-icu + always: + - name: Wait for pretty response + uri: + url: http://localhost:9200/?pretty + register: result + until: result.status == 200 + retries: 60 + delay: 1 + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/elasticsearch/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.elasticsearch + vars: + manala_elasticsearch_environment_template: environment/elasticsearch/elasticsearch.j2 + manala_elasticsearch_environment: + # See: https://github.com/elastic/elasticsearch/issues/57018#issuecomment-694703398 + ES_JAVA_OPTS: -Xms256m -Xmx256m -Djava.io.tmpdir=/var/log/elasticsearch + - name: Role - Dict + import_role: + name: manala.roles.elasticsearch + tasks_from: config + vars: + manala_elasticsearch_config_file: "{{ tests_dir }}/dict" + manala_elasticsearch_config_template: ~ + manala_elasticsearch_config: + cluster: + name: foo + path.data: /foo/bar + - name: Role - Content + import_role: + name: manala.roles.elasticsearch + tasks_from: config + vars: + manala_elasticsearch_config_file: "{{ tests_dir }}/content" + manala_elasticsearch_config_template: ~ + manala_elasticsearch_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.elasticsearch + tasks_from: config + vars: + manala_elasticsearch_config_file: "{{ tests_dir }}/template" + manala_elasticsearch_config_template: fixtures/template.j2 + manala_elasticsearch_config: ~ + always: + - name: Wait for pretty response + uri: + url: http://localhost:9200/?pretty + register: result + until: result.status == 200 + retries: 60 + delay: 1 + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +############### +# Environment # +############### + +- name: Environment + tags: [environment] + hosts: debian + vars: + tests_dir: /molecule/elasticsearch/environment + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.elasticsearch + vars: + manala_elasticsearch_environment_template: environment/elasticsearch/elasticsearch.j2 + manala_elasticsearch_environment: + # See: https://github.com/elastic/elasticsearch/issues/57018#issuecomment-694703398 + ES_JAVA_OPTS: -Xms256m -Xmx256m -Djava.io.tmpdir=/var/log/elasticsearch + - name: Role - Dict + import_role: + name: manala.roles.elasticsearch + tasks_from: environment + vars: + manala_elasticsearch_environment_file: "{{ tests_dir }}/dict" + manala_elasticsearch_environment_template: ~ + manala_elasticsearch_environment: + ES_JAVA_OPTS: -Xms1g -Xmx1g + FOO: bar + - name: Role - Content + import_role: + name: manala.roles.elasticsearch + tasks_from: environment + vars: + manala_elasticsearch_environment_file: "{{ tests_dir }}/content" + manala_elasticsearch_environment_template: ~ + manala_elasticsearch_environment: | + Content + - name: Role - Template + import_role: + name: manala.roles.elasticsearch + tasks_from: environment + vars: + manala_elasticsearch_environment_file: "{{ tests_dir }}/template" + manala_elasticsearch_environment_template: fixtures/template.j2 + manala_elasticsearch_environment: ~ + always: + - name: Wait for pretty response + uri: + url: http://localhost:9200/?pretty + register: result + until: result.status == 200 + retries: 60 + delay: 1 + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/environment.yml.j2') }}" diff --git a/molecule/elasticsearch.7/fixtures/template.j2 b/molecule/elasticsearch.7/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/elasticsearch.7/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/elasticsearch.7/goss/config.yml.j2 b/molecule/elasticsearch.7/goss/config.yml.j2 new file mode 100644 index 000000000..7cdbc3512 --- /dev/null +++ b/molecule/elasticsearch.7/goss/config.yml.j2 @@ -0,0 +1,29 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: elasticsearch + mode: "0660" + contains: + - "cluster:" + - " name: foo" + - "path.data: /foo/bar" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: elasticsearch + mode: "0660" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: elasticsearch + mode: "0660" + contains: + - "/^Template$/" diff --git a/roles/elasticsearch/tests/0004_default.7.goss.yml b/molecule/elasticsearch.7/goss/default.yml.j2 similarity index 100% rename from roles/elasticsearch/tests/0004_default.7.goss.yml rename to molecule/elasticsearch.7/goss/default.yml.j2 diff --git a/molecule/elasticsearch.7/goss/environment.yml.j2 b/molecule/elasticsearch.7/goss/environment.yml.j2 new file mode 100644 index 000000000..c71a90cad --- /dev/null +++ b/molecule/elasticsearch.7/goss/environment.yml.j2 @@ -0,0 +1,28 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: elasticsearch + mode: "0660" + contains: + - "/^ES_JAVA_OPTS=\"-Xms1g -Xmx1g\"$/" + - "/^FOO=\"bar\"$/" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: elasticsearch + mode: "0660" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: elasticsearch + mode: "0660" + contains: + - "/^Template$/" diff --git a/molecule/elasticsearch.7/molecule.yml b/molecule/elasticsearch.7/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/elasticsearch.7/prepare.yml b/molecule/elasticsearch.7/prepare.yml new file mode 100644 index 000000000..9a5bc2132 --- /dev/null +++ b/molecule/elasticsearch.7/prepare.yml @@ -0,0 +1,13 @@ +--- +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - elasticsearch@elasticsearch_7 + - name: Java + import_role: + name: manala.roles.java diff --git a/molecule/environment/converge.yml b/molecule/environment/converge.yml new file mode 100644 index 000000000..db7bab92b --- /dev/null +++ b/molecule/environment/converge.yml @@ -0,0 +1,57 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + vars: + tests_dir: /molecule/environment/default + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - name: Pam file # noqa risky-file-permissions + copy: + dest: /etc/environment + content: | + _FOO="bar" + _BAR="123" + - name: Zsh directory # noqa risky-file-permissions + file: + path: /etc/zsh + state: directory + - name: Zsh file # noqa risky-file-permissions + copy: + dest: /etc/zsh/zshenv + content: | + # /etc/zsh/zshenv + - name: File # noqa risky-file-permissions + copy: + dest: "{{ tests_dir }}/file" + content: | + # {{ tests_dir }}/file + - block: + - name: Role + import_role: + name: manala.roles.environment + vars: + manala_environment_files: + - pam + - zsh + - file: "{{ tests_dir }}/file" + export: true + manala_environment_variables: + FOO: bar + BAR: 123 + BAZ: 1.2 + QUX: foo=bar + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/environment/goss/default.yml.j2 b/molecule/environment/goss/default.yml.j2 new file mode 100644 index 000000000..859cf1120 --- /dev/null +++ b/molecule/environment/goss/default.yml.j2 @@ -0,0 +1,31 @@ +--- + +file: + /etc/environment: + exists: true + filetype: file + contains: + - '_FOO="bar"' + - '_BAR="123"' + - 'BAR="123"' + - 'BAZ="1.2"' + - 'FOO="bar"' + - 'QUX="foo=bar"' + /etc/zsh/zshenv: + exists: true + filetype: file + contains: + - '# /etc/zsh/zshenv' + - 'export BAR="123"' + - 'export BAZ="1.2"' + - 'export FOO="bar"' + - 'export QUX="foo=bar"' + {{ tests_dir }}/file: + exists: true + filetype: file + contains: + - '# {{ tests_dir }}/file' + - 'export BAR="123"' + - 'export BAZ="1.2"' + - 'export FOO="bar"' + - 'export QUX="foo=bar"' diff --git a/molecule/environment/molecule.yml b/molecule/environment/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/fail2ban/converge.yml b/molecule/fail2ban/converge.yml new file mode 100644 index 000000000..ca90be098 --- /dev/null +++ b/molecule/fail2ban/converge.yml @@ -0,0 +1,64 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.fail2ban + vars: + manala_fail2ban_config: | + [ssh] + enabled = false + [sshd] + enabled = false + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/fail2ban/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Content + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.fail2ban + vars: + manala_fail2ban_config_file: "{{ tests_dir }}/content" + manala_fail2ban_config_template: ~ + manala_fail2ban_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.fail2ban + tasks_from: config + vars: + manala_fail2ban_config_file: "{{ tests_dir }}/template" + manala_fail2ban_config_template: fixtures/template.j2 + manala_fail2ban_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" diff --git a/molecule/fail2ban/fixtures/template.j2 b/molecule/fail2ban/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/fail2ban/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/fail2ban/goss/config.yml.j2 b/molecule/fail2ban/goss/config.yml.j2 new file mode 100644 index 000000000..30ac39316 --- /dev/null +++ b/molecule/fail2ban/goss/config.yml.j2 @@ -0,0 +1,19 @@ +--- + +file: + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/fail2ban/goss/default.yml.j2 b/molecule/fail2ban/goss/default.yml.j2 new file mode 100644 index 000000000..b37664e00 --- /dev/null +++ b/molecule/fail2ban/goss/default.yml.j2 @@ -0,0 +1,10 @@ +--- + +package: + fail2ban: + installed: true + +service: + fail2ban: + enabled: true + running: true diff --git a/molecule/fail2ban/molecule.yml b/molecule/fail2ban/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/files/converge.yml b/molecule/files/converge.yml new file mode 100644 index 000000000..582137605 --- /dev/null +++ b/molecule/files/converge.yml @@ -0,0 +1,840 @@ +--- + +############ +# Defaults # +############ + +- name: Defaults + tags: [defaults] + hosts: debian + vars: + tests_dir: /molecule/files/defaults + gather_facts: false + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + # Default + - block: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/default" + state: directory + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes_defaults: + - user: nobody + - path: ^{{ tests_dir }}/default/root + user: root + group: root + - path: ^{{ tests_dir }}/default/nobody + group: nogroup + - path: ^{{ tests_dir }}/default/mail + user: mail + group: mail + manala_files_attributes: + - path: "{{ tests_dir }}/default/root" + state: touch + # Flatten + - + - path: "{{ tests_dir }}/default/nobody" + state: touch + - path: "{{ tests_dir }}/default/mail" + state: touch + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/defaults.yml.j2') }}" + +######## +# File # +######## + +- name: File + tags: [file] + hosts: debian + vars: + tests_dir: /molecule/files/file + gather_facts: false + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + # Default + - block: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/default" + state: directory + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/default/default" + # Parents + - block: + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes_defaults: + - path: ^{{ tests_dir }}/parents_defaults + parents: true + manala_files_attributes: + - path: "{{ tests_dir }}/parents/file" + parents: true + - path: "{{ tests_dir }}/parents_defaults/file" + - path: "{{ tests_dir }}/parents_unexisting/file" + rescue: + - debug: + msg: A planned error has been caught... + # File already exists as empty directory + - block: + - name: Directories # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: directory + loop: + - file_directory_empty + - file_directory_empty/file_force + - file_directory_empty/file + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/file_directory_empty/file_force" + force: true + - path: "{{ tests_dir }}/file_directory_empty/file" + rescue: + - debug: + msg: A planned error has been caught... + # File already exists as full directory + - block: + - name: Directories # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: directory + loop: + - file_directory_full + - file_directory_full/file_force + - file_directory_full/file + - name: Files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: + - file_directory_full/file_force/file + - file_directory_full/file/file + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/file_directory_full/file_force" + force: true + - path: "{{ tests_dir }}/file_directory_full/file" + rescue: + - debug: + msg: A planned error has been caught... + # File already exists as link to file + - block: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/file_link_file" + state: directory + - name: File # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/file_link_file/link_file" + state: touch + - name: Links # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + src: "{{ tests_dir }}/file_link_file/link_file" + state: link + loop: + - file_link_file/file_force + - file_link_file/file + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/file_link_file/file_force" + force: true + - path: "{{ tests_dir }}/file_link_file/file" + # File already exists as link to directory + - block: + - name: Directories # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: directory + loop: + - file_link_directory + - file_link_directory/link_file + - name: Links # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + src: "{{ tests_dir }}/file_link_directory/link_file" + state: link + loop: + - file_link_directory/file_force + - file_link_directory/file + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/file_link_directory/file_force" + force: true + - path: "{{ tests_dir }}/file_link_directory/file" + rescue: + - debug: + msg: A planned error has been caught... + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/file.yml.j2') }}" + +######## +# Link # +######## + +- name: Link + tags: [link] + hosts: debian + vars: + tests_dir: /molecule/files/link + gather_facts: false + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - name: File # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/file" + state: touch + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/directory" + state: directory + - block: + # Default + - block: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/default" + state: directory + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + # Link to file + - path: "{{ tests_dir }}/default/link_file" + src: "{{ tests_dir }}/file" + state: link + # Link to link to file + - path: "{{ tests_dir }}/default/link_link_file" + src: "{{ tests_dir }}/default/link_file" + state: link + # Flatten + - + # Link to directory + - path: "{{ tests_dir }}/default/link_directory" + src: "{{ tests_dir }}/directory" + state: link + # Link to link to directory + - path: "{{ tests_dir }}/default/link_link_directory" + src: "{{ tests_dir }}/default/link_directory" + state: link + # Parents + - block: + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes_defaults: + - path: ^{{ tests_dir }}/parents_defaults + parents: true + manala_files_attributes: + - path: "{{ tests_dir }}/parents/link" + src: "{{ tests_dir }}/file" + state: link + parents: true + - path: "{{ tests_dir }}/parents_defaults/link" + src: "{{ tests_dir }}/file" + state: link + - path: "{{ tests_dir }}/parents_unexisting/link" + src: "{{ tests_dir }}/file" + state: link_directory + rescue: + - debug: + msg: A planned error has been caught... + # Wrong + - block: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/wrong" + state: directory + - name: Link # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/wrong/link" + src: "{{ tests_dir }}/file" + state: link + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/wrong/link" + src: "{{ tests_dir }}/directory" + state: link + # Link already exists as file + - block: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/link_file" + state: directory + - name: Files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: + - link_file/link_force + - link_file/link + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/link_file/link_force" + src: "{{ tests_dir }}/file" + state: link + force: true + - path: "{{ tests_dir }}/link_file/link" + src: "{{ tests_dir }}/file" + state: link + rescue: + - debug: + msg: A planned error has been caught... + # Link already exists as empty directory + - block: + - name: Directories # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: directory + loop: + - link_directory_empty + - link_directory_empty/link_force + - link_directory_empty/link + - import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/link_directory_empty/link_force" + src: "{{ tests_dir }}/file" + state: link + force: true + - path: "{{ tests_dir }}/link_directory_empty/link" + src: "{{ tests_dir }}/file" + state: link + rescue: + - debug: + msg: A planned error has been caught... + # Link already exists as full directory + - block: + - name: Directories # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: directory + loop: + - link_directory_full + - link_directory_full/link_force + - link_directory_full/link + - name: Files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: + - link_directory_full/link_force/file + - link_directory_full/link/file + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/link_directory_full/link_force" + src: "{{ tests_dir }}/file" + state: link + force: true + - path: "{{ tests_dir }}/link_directory_full/link" + src: "{{ tests_dir }}/file" + state: link + rescue: + - debug: + msg: A planned error has been caught... + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/link.yml.j2') }}" + +############# +# Directory # +############# + +- name: Directory + tags: [directory] + hosts: debian + vars: + tests_dir: /molecule/files/directory + gather_facts: false + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + # Default + - block: + - name: File # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/default" + state: directory + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/default/default" + state: directory + # Directory already exists as file + - block: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/directory_file" + state: directory + - name: Files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: + - directory_file/directory_force + - directory_file/directory + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/directory_file/directory_force" + state: directory + force: true + - path: "{{ tests_dir }}/directory_file/directory" + state: directory + rescue: + - debug: + msg: A planned error has been caught... + # Directory already exists as link to file + - block: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/directory_link_file" + state: directory + - name: File # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/directory_link_file/link_file" + state: touch + - name: Link # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + src: "{{ tests_dir }}/directory_link_file/link_file" + state: link + loop: + - directory_link_file/directory_force + - directory_link_file/directory + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/directory_link_file/directory_force" + state: directory + force: true + - path: /"tmp/directory/directory_link_file/directory" + state: directory + rescue: + - debug: + msg: A planned error has been caught... + # Directory already exists as link to directory + - block: + - name: Directories # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: directory + loop: + - directory_link_directory + - directory_link_directory/link_directory + - name: Links # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + src: "{{ tests_dir }}/directory_link_directory/link_directory" + state: link + loop: + - directory_link_directory/directory_force + - directory_link_directory/directory + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/directory_link_directory/directory_force" + state: directory + force: true + - path: "{{ tests_dir }}/directory_link_directory/directory" + state: directory + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/directory.yml.j2') }}" + +######## +# Copy # +######## + +- name: Copy + tags: [copy] + hosts: debian + vars: + tests_dir: /molecule/files/copy + gather_facts: false + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + # Default + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/default" + state: directory + - name: File # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/default/absent" + state: touch + - block: + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/default/default" + copy: fixtures/file + # Flatten + - + - path: "{{ tests_dir }}/default/present" + copy: fixtures/file + state: present + - path: "{{ tests_dir }}/default/absent" + state: absent + - path: "{{ tests_dir }}/default/ignore" + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/copy.yml.j2') }}" + +####### +# Url # +####### + +- name: Url + tags: [url] + hosts: debian + vars: + tests_dir: /molecule/files/url + gather_facts: false + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + # Default + - block: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/default" + state: directory + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/default/perdu" + url: http://www.perdu.com/ + # Flatten + - + - path: "{{ tests_dir }}/default/alt-galaxy.tar.gz" + url: https://github.com/gantsign/alt-galaxy/releases/download/1.4.1/alt-galaxy_darwin_amd64.tar.gz + unarchive: true + creates: "{{ tests_dir }}/default/alt-galaxy" + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/url.yml.j2') }}" + +########### +# Content # +########### + +- name: Content + tags: [content] + hosts: debian + vars: + tests_dir: /molecule/files/content + gather_facts: false + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + # Default + - block: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/default" + state: directory + - name: File # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/default/absent" + state: touch + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/default/default" + content: | + Content default + # Flatten + - + - path: "{{ tests_dir }}/default/present" + content: | + Content present + state: present + - path: "{{ tests_dir }}/default/absent" + state: absent + - path: "{{ tests_dir }}/default/ignore" + state: ignore + # Parents + - block: + - name: Roles + import_role: + name: manala.roles.files + vars: + manala_files_attributes_defaults: + - path: ^{{ tests_dir }}/parents_defaults + parents: true + manala_files_attributes: + - path: "{{ tests_dir }}/parents/content" + content: | + Content parents default + parents: true + - path: "{{ tests_dir }}/parents_defaults/content" + content: | + Content defaults parents + - path: "{{ tests_dir }}/parents_unexisting/content" + content: | + Content defaults parents + rescue: + - debug: + msg: A planned error has been caught... + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/content.yml.j2') }}" + +############ +# Template # +############ + +- name: Template + tags: [template] + hosts: debian + vars: + tests_dir: /molecule/files/template + gather_facts: false + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + # Default + - block: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/default" + state: directory + - name: File # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/default/absent" + state: touch + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + - path: "{{ tests_dir }}/default/default" + template: fixtures/template.j2 + # Flatten + - + - path: "{{ tests_dir }}/default/present" + template: fixtures/template.j2 + state: present + - path: "{{ tests_dir }}/default/absent" + state: absent + - path: "{{ tests_dir }}/default/ignore" + state: ignore + # Parents + - block: + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes_defaults: + - path: ^{{ tests_dir }}/parents_defaults + parents: true + manala_files_attributes: + - path: "{{ tests_dir }}/parents/template" + template: fixtures/template.j2 + parents: true + - path: "{{ tests_dir }}/parents_defaults/template" + template: fixtures/template.j2 + - path: "{{ tests_dir }}/parents_unexisting/template" + template: fixtures/template.j2 + rescue: + - debug: + msg: A planned error has been caught... + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/template.yml.j2') }}" + +################## +# Link Directory # +################## + +- name: Link Directory + tags: [link_directory] + hosts: debian + vars: + tests_dir: /molecule/files/link_directory + gather_facts: false + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + # Default + - block: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/default" + state: directory + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + # Default + - path: "{{ tests_dir }}/default/link_directory" + src: "{{ tests_dir }}/default/directory" + state: link_directory + # Sub directory + - path: "{{ tests_dir }}/default/link_directory_sub" + src: "{{ tests_dir }}/default/directory_sub/directory" + state: link_directory + # Permissions + - path: "{{ tests_dir }}/default/link_permissions" + src: "{{ tests_dir }}/default/directory_permissions" + state: link_directory + user: backup + group: games + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/link_directory.yml.j2') }}" + +############# +# Link File # +############# + +- name: Link File + tags: [link_file] + hosts: debian + vars: + tests_dir: /molecule/files/link_file + gather_facts: false + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + # Default + - block: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/default" + state: directory + - name: Role + import_role: + name: manala.roles.files + vars: + manala_files_attributes: + # Default + - path: "{{ tests_dir }}/default/link_file" + src: "{{ tests_dir }}/default/file" + state: link_file + # Permissions + - path: "{{ tests_dir }}/default/link_permissions" + src: "{{ tests_dir }}/default/file_permissions" + state: link_file + user: backup + group: games + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/link_file.yml.j2') }}" diff --git a/molecule/files/fixtures/file b/molecule/files/fixtures/file new file mode 100644 index 000000000..a0fe4515f --- /dev/null +++ b/molecule/files/fixtures/file @@ -0,0 +1 @@ +File \ No newline at end of file diff --git a/molecule/files/fixtures/template.j2 b/molecule/files/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/files/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/files/goss/content.yml.j2 b/molecule/files/goss/content.yml.j2 new file mode 100644 index 000000000..ed7c0d038 --- /dev/null +++ b/molecule/files/goss/content.yml.j2 @@ -0,0 +1,37 @@ +--- + +file: + # Default + {{ tests_dir }}/default/default: + exists: true + filetype: file + contains: + - Content default + {{ tests_dir }}/default/present: + exists: true + filetype: file + contains: + - Content present + {{ tests_dir }}/default/absent: + exists: false + {{ tests_dir }}/default/ignore: + exists: false + # Parents + {{ tests_dir }}/parents: + exists: true + filetype: directory + {{ tests_dir }}/parents/content: + exists: true + filetype: file + contains: + - Content parents default + {{ tests_dir }}/parents_defaults: + exists: true + filetype: directory + {{ tests_dir }}/parents_defaults/content: + exists: true + filetype: file + contains: + - Content defaults parents + {{ tests_dir }}/parents_unexisting/content: + exists: false diff --git a/molecule/files/goss/copy.yml.j2 b/molecule/files/goss/copy.yml.j2 new file mode 100644 index 000000000..909b30e3e --- /dev/null +++ b/molecule/files/goss/copy.yml.j2 @@ -0,0 +1,18 @@ +--- + +file: + # Default + {{ tests_dir }}/default/default: + exists: true + filetype: file + contains: + - "/^File$/" + {{ tests_dir }}/default/present: + exists: true + filetype: file + contains: + - "/^File$/" + {{ tests_dir }}/default/absent: + exists: false + {{ tests_dir }}/default/ignore: + exists: false \ No newline at end of file diff --git a/molecule/files/goss/defaults.yml.j2 b/molecule/files/goss/defaults.yml.j2 new file mode 100644 index 000000000..fa525bf41 --- /dev/null +++ b/molecule/files/goss/defaults.yml.j2 @@ -0,0 +1,18 @@ +--- + +file: + {{ tests_dir }}/default/root: + exists: true + filetype: file + owner: root + group: root + {{ tests_dir }}/default/nobody: + exists: true + filetype: file + owner: nobody + group: nogroup + {{ tests_dir }}/default/mail: + exists: true + filetype: file + owner: mail + group: mail diff --git a/molecule/files/goss/directory.yml.j2 b/molecule/files/goss/directory.yml.j2 new file mode 100644 index 000000000..5e5fd0b4e --- /dev/null +++ b/molecule/files/goss/directory.yml.j2 @@ -0,0 +1,31 @@ +--- + +file: + # Default + {{ tests_dir }}/default/default: + exists: true + filetype: directory + # Directory already exists as file + {{ tests_dir }}/directory_file/directory_force: + exists: true + filetype: directory + {{ tests_dir }}/directory_file/directory: + exists: true + filetype: file + # Directory already exists as link to file + {{ tests_dir }}/directory_link_file/directory_force: + exists: true + filetype: directory + {{ tests_dir }}/directory_link_file/directory: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/directory_link_file/link_file + # Directory already exists as link to directory + {{ tests_dir }}/directory_link_directory/directory_force: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/directory_link_directory/link_directory + {{ tests_dir }}/directory_link_directory/directory: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/directory_link_directory/link_directory diff --git a/molecule/files/goss/file.yml.j2 b/molecule/files/goss/file.yml.j2 new file mode 100644 index 000000000..6fc53c731 --- /dev/null +++ b/molecule/files/goss/file.yml.j2 @@ -0,0 +1,53 @@ +--- + +file: + # Default + {{ tests_dir }}/default/default: + exists: true + filetype: file + # Parents + {{ tests_dir }}/parents: + exists: true + filetype: directory + {{ tests_dir }}/parents/file: + exists: true + filetype: file + {{ tests_dir }}/parents_defaults: + exists: true + filetype: directory + {{ tests_dir }}/parents_defaults/file: + exists: true + filetype: file + {{ tests_dir }}/parents_unexisting/file: + exists: false + # File already exists as empty directory + {{ tests_dir }}/file_directory_empty/file_force: + exists: true + filetype: file + {{ tests_dir }}/file_directory_empty/file: + exists: true + filetype: directory + # File already exists as full directory + {{ tests_dir }}/file_directory_full/file_force: + exists: true + filetype: file + {{ tests_dir }}/file_directory_full/file: + exists: true + filetype: directory + # File already exists as link to file + {{ tests_dir }}/file_link_file/file_force: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/file_link_file/link_file + {{ tests_dir }}/file_link_file/file: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/file_link_file/link_file + # File already exists as link to directory + {{ tests_dir }}/file_link_directory/file_force: + exists: true + filetype: file + {{ tests_dir }}/file_link_directory/file: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/file_link_directory/link_file diff --git a/molecule/files/goss/link.yml.j2 b/molecule/files/goss/link.yml.j2 new file mode 100644 index 000000000..fc5a6c582 --- /dev/null +++ b/molecule/files/goss/link.yml.j2 @@ -0,0 +1,69 @@ +--- + +file: + # Default - Link to file + {{ tests_dir }}/default/link_file: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/file + # Default - Link to link to file + {{ tests_dir }}/default/link_link_file: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/default/link_file + # Default - Link to directory + {{ tests_dir }}/default/link_directory: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/directory + # Default - Link to link to directory + {{ tests_dir }}/default/link_link_directory: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/default/link_directory + # Parents + {{ tests_dir }}/parents: + exists: true + filetype: directory + {{ tests_dir }}/parents/link: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/file + {{ tests_dir }}/parents_defaults: + exists: true + filetype: directory + {{ tests_dir }}/parents_defaults/link: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/file + {{ tests_dir }}/parents_unexisting/link: + exists: false + # Wrong + {{ tests_dir }}/wrong/link: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/directory + # Link already exists as file + {{ tests_dir }}/link_file/link_force: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/file + {{ tests_dir }}/link_file/link: + exists: true + filetype: file + # Link already exists as empty directory + {{ tests_dir }}/link_directory_empty/link_force: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/file + {{ tests_dir }}/link_directory_empty/link: + exists: true + filetype: directory + # Link already exists as full directory + {{ tests_dir }}/link_directory_full/link_force: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/file + {{ tests_dir }}/link_directory_full/link: + exists: true + filetype: directory \ No newline at end of file diff --git a/molecule/files/goss/link_directory.yml.j2 b/molecule/files/goss/link_directory.yml.j2 new file mode 100644 index 000000000..2be01e43f --- /dev/null +++ b/molecule/files/goss/link_directory.yml.j2 @@ -0,0 +1,29 @@ +--- + +file: + # Default - Default + {{ tests_dir }}/default/link_directory: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/default/directory + {{ tests_dir }}/default/directory: + exists: true + filetype: directory + # Default - Sub directory + {{ tests_dir }}/default/link_directory_sub: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/default/directory_sub/directory + {{ tests_dir }}/default/directory_sub/directory: + exists: true + filetype: directory + # Default - Permissions + {{ tests_dir }}/default/link_permissions: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/default/directory_permissions + {{ tests_dir }}/default/directory_permissions: + exists: true + filetype: directory + owner: backup + group: games diff --git a/molecule/files/goss/link_file.yml.j2 b/molecule/files/goss/link_file.yml.j2 new file mode 100644 index 000000000..fbd0e1aeb --- /dev/null +++ b/molecule/files/goss/link_file.yml.j2 @@ -0,0 +1,21 @@ +--- + +file: + # Default - Default + {{ tests_dir }}/default/link_file: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/default/file + {{ tests_dir }}/default/file: + exists: true + filetype: file + # Default - Permissions + {{ tests_dir }}/default/link_permissions: + exists: true + filetype: symlink + linked-to: {{ tests_dir }}/default/file_permissions + {{ tests_dir }}/default/file_permissions: + exists: true + filetype: file + owner: backup + group: games diff --git a/molecule/files/goss/template.yml.j2 b/molecule/files/goss/template.yml.j2 new file mode 100644 index 000000000..d9653b8ab --- /dev/null +++ b/molecule/files/goss/template.yml.j2 @@ -0,0 +1,37 @@ +--- + +file: + # Default + {{ tests_dir }}/default/default: + exists: true + filetype: file + contains: + - "/^Template$/" + {{ tests_dir }}/default/present: + exists: true + filetype: file + contains: + - "/^Template$/" + {{ tests_dir }}/default/absent: + exists: false + {{ tests_dir }}/default/ignore: + exists: false + # Parents + {{ tests_dir }}/parents: + exists: true + filetype: directory + {{ tests_dir }}/parents/template: + exists: true + filetype: file + contains: + - "/^Template$/" + {{ tests_dir }}/parents_defaults: + exists: true + filetype: directory + {{ tests_dir }}/parents_defaults/template: + exists: true + filetype: file + contains: + - "/^Template$/" + {{ tests_dir }}/parents_unexisting/template: + exists: false diff --git a/molecule/files/goss/url.yml.j2 b/molecule/files/goss/url.yml.j2 new file mode 100644 index 000000000..638f011c2 --- /dev/null +++ b/molecule/files/goss/url.yml.j2 @@ -0,0 +1,16 @@ +--- + +file: + # Default + {{ tests_dir }}/default/perdu: + exists: true + filetype: file + contains: + - Perdu sur l'Internet ? + - Pas de panique, on va vous aider + {{ tests_dir }}/default/alt-galaxy.tar.gz: + exists: true + filetype: file + {{ tests_dir }}/default/alt-galaxy: + exists: true + filetype: file diff --git a/molecule/files/molecule.yml b/molecule/files/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/git/converge.yml b/molecule/git/converge.yml new file mode 100644 index 000000000..13a9326dc --- /dev/null +++ b/molecule/git/converge.yml @@ -0,0 +1,87 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + vars: + tests_dir: /molecule/git/default + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + mode: "0777" + loop: [absent, directory] + - block: + - name: Role + import_role: + name: manala.roles.git + vars: + manala_git_repositories: + - repo: https://github.com/manala/ansible-role-git.git + dest: "{{ tests_dir }}/ansible-role-git" + - repo: https://github.com/manala/ansible-role-git.git + dest: "{{ tests_dir }}/ansible-role-git-user" + user: games + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/git/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + name: manala.roles.git + tasks_from: config + vars: + manala_git_config_file: "{{ tests_dir }}/dict" + manala_git_config_template: ~ + manala_git_config: + foo: + foo: true + bar: false + bar: + foo: bar + bar: 123 + - name: Role - Content + import_role: + name: manala.roles.git + tasks_from: config + vars: + manala_git_config_file: "{{ tests_dir }}/content" + manala_git_config_template: ~ + manala_git_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.git + tasks_from: config + vars: + manala_git_config_file: "{{ tests_dir }}/template" + manala_git_config_template: fixtures/template.j2 + manala_git_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" diff --git a/molecule/git/fixtures/template.j2 b/molecule/git/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/git/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/git/goss/config.yml.j2 b/molecule/git/goss/config.yml.j2 new file mode 100644 index 000000000..81f375259 --- /dev/null +++ b/molecule/git/goss/config.yml.j2 @@ -0,0 +1,32 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[foo]" + - " foo = true" + - " bar = false" + - "[bar]" + - " foo = bar" + - " bar = 123" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/git/goss/default.yml.j2 b/molecule/git/goss/default.yml.j2 new file mode 100644 index 000000000..25e0a2349 --- /dev/null +++ b/molecule/git/goss/default.yml.j2 @@ -0,0 +1,18 @@ +--- + +package: + git: + installed: true + +file: + {{ tests_dir }}/ansible-role-git/.git: + exists: true + filetype: directory + owner: root + group: root + mode: "0755" + {{ tests_dir }}/ansible-role-git-user/.git: + exists: true + filetype: directory + owner: games + mode: "0755" diff --git a/molecule/git/molecule.yml b/molecule/git/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/git/prepare.yml b/molecule/git/prepare.yml new file mode 100644 index 000000000..b7d9b3146 --- /dev/null +++ b/molecule/git/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Packages + apt: + name: [sudo] + install_recommends: false + update_cache: true + cache_valid_time: 3600 diff --git a/molecule/gitlab/converge.yml b/molecule/gitlab/converge.yml new file mode 100644 index 000000000..b1f035859 --- /dev/null +++ b/molecule/gitlab/converge.yml @@ -0,0 +1,109 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian:!debian.bullseye + tasks: + - block: + - name: Role + import_role: + name: manala.roles.gitlab + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian!debian.bullseye + vars: + tests_dir: /molecule/gitlab/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.gitlab + vars: + manala_gitlab_configs_exclusive: false + manala_gitlab_configs_dir: "{{ tests_dir }}/default" + manala_gitlab_configs_defaults: {} + manala_gitlab_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.gitlab + tasks_from: configs + vars: + manala_gitlab_configs_exclusive: false + manala_gitlab_configs_dir: "{{ tests_dir }}/defaults" + manala_gitlab_configs_defaults: + template: fixtures/template.j2 + manala_gitlab_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.gitlab + tasks_from: configs + vars: + manala_gitlab_configs_exclusive: true + manala_gitlab_configs_dir: "{{ tests_dir }}/exclusive" + manala_gitlab_configs_defaults: {} + manala_gitlab_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" diff --git a/molecule/gitlab/fixtures/template.j2 b/molecule/gitlab/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/gitlab/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/gitlab/fixtures/template_file.j2 b/molecule/gitlab/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/gitlab/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/gitlab/goss/configs.yml.j2 b/molecule/gitlab/goss/configs.yml.j2 new file mode 100644 index 000000000..6533cbc38 --- /dev/null +++ b/molecule/gitlab/goss/configs.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/roles/gitlab/tests/0000_default.goss.yml b/molecule/gitlab/goss/default.yml.j2 similarity index 100% rename from roles/gitlab/tests/0000_default.goss.yml rename to molecule/gitlab/goss/default.yml.j2 diff --git a/molecule/gitlab/molecule.yml b/molecule/gitlab/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/gitlab/prepare.yml b/molecule/gitlab/prepare.yml new file mode 100644 index 000000000..e1f1b3415 --- /dev/null +++ b/molecule/gitlab/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - gitlab-ce@gitlab-ce diff --git a/molecule/glusterfs.6.1/converge.yml b/molecule/glusterfs.6.1/converge.yml new file mode 100644 index 000000000..43d908f6b --- /dev/null +++ b/molecule/glusterfs.6.1/converge.yml @@ -0,0 +1,87 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.glusterfs + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Volumes # +########### + +- name: Volumes + tags: [volumes] + hosts: + - debian.stretch + - debian.buster + vars: + tests_dir: /molecule/glusterfs/volumes + tasks: + - name: Directories # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: directory + loop: [absent, present, test_1, test_2, test_3] + - block: + - name: Role - 1 + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.glusterfs + vars: + manala_glusterfs_volumes: + - name: volume_ignore + state: ignore + - name: volume_absent + bricks: "{{ tests_dir }}/absent" + cluster: + - debian.{{ ansible_distribution_release }} + force: true + - name: volume_present + bricks: "{{ tests_dir }}/present" + cluster: + - debian.{{ ansible_distribution_release }} + force: true + # Flatten + - + - name: volume_test + bricks: "{{ tests_dir }}/test_1" + cluster: + - debian.{{ ansible_distribution_release }} + options: + storage.owner-gid: "1337" + storage.owner-uid: "1337" + nfs.disable: "off" + force: true + - name: Role - 2 + import_role: + name: manala.roles.glusterfs + tasks_from: volumes + vars: + manala_glusterfs_volumes: + - name: volume_absent + state: absent + - name: volume_test + bricks: "{{ tests_dir }}/test_2,{{ tests_dir }}/test_3" + cluster: + - debian.{{ ansible_distribution_release }} + force: true + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/volumes.yml.j2') }}" diff --git a/molecule/glusterfs.6.1/goss/default.yml.j2 b/molecule/glusterfs.6.1/goss/default.yml.j2 new file mode 100644 index 000000000..25b08abfd --- /dev/null +++ b/molecule/glusterfs.6.1/goss/default.yml.j2 @@ -0,0 +1,10 @@ +--- + +package: + glusterfs-server: + installed: true + +service: + glusterd: + enabled: true + running: true diff --git a/molecule/glusterfs.6.1/goss/volumes.yml.j2 b/molecule/glusterfs.6.1/goss/volumes.yml.j2 new file mode 100644 index 000000000..a63909b37 --- /dev/null +++ b/molecule/glusterfs.6.1/goss/volumes.yml.j2 @@ -0,0 +1,39 @@ +--- + +command: + gluster volume info volume_ignore: + exit-status: 0 + stderr: + - "Volume volume_ignore does not exist" + gluster volume info volume_absent: + exit-status: 0 + stderr: + - "Volume volume_absent does not exist" + gluster volume info volume_present: + exit-status: 0 + stderr: + - "Volume volume_present does not exist" + gluster volume info volume_test: + exit-status: 0 + stderr: + - "Volume volume_test does not exist" + +command: + gluster volume info: + exit-status: 0 + stdout: + # Present + - "Volume Name: volume_present" + - "Status: Started" + - "Bricks:" + - "Brick1: debian.{{ ansible_distribution_release}}:{{ tests_dir}}/present" + # Test + - "Volume Name: volume_test" + - "Status: Started" + - "Bricks:" + - "Brick1: debian.{{ ansible_distribution_release }}:{{ tests_dir}}/test_1" + - "Brick2: debian.{{ ansible_distribution_release }}:{{ tests_dir}}/test_2" + - "Brick3: debian.{{ ansible_distribution_release }}:{{ tests_dir}}/test_3" + - "storage.owner-uid: 1337" + - "storage.owner-gid: 1337" + - "nfs.disable: off" diff --git a/molecule/glusterfs.6.1/molecule.yml b/molecule/glusterfs.6.1/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/glusterfs.6.1/prepare.yml b/molecule/glusterfs.6.1/prepare.yml new file mode 100644 index 000000000..ed4415d82 --- /dev/null +++ b/molecule/glusterfs.6.1/prepare.yml @@ -0,0 +1,12 @@ +--- +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - glusterfs@glusterfs_6_1 diff --git a/molecule/gomplate/converge.yml b/molecule/gomplate/converge.yml new file mode 100644 index 000000000..03a7f16c8 --- /dev/null +++ b/molecule/gomplate/converge.yml @@ -0,0 +1,48 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.gomplate + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Version # +########### + +- name: Version + tags: [version] + hosts: debian + vars: + tests_dir: /molecule/gomplate/version + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Fixed + import_role: + name: manala.roles.gomplate + tasks_from: install + vars: + manala_gomplate_bin: "{{ tests_dir }}/fixed" + manala_gomplate_version: 3.8.0 + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/version.yml.j2') }}" diff --git a/molecule/gomplate/goss/default.yml.j2 b/molecule/gomplate/goss/default.yml.j2 new file mode 100644 index 000000000..0ba798887 --- /dev/null +++ b/molecule/gomplate/goss/default.yml.j2 @@ -0,0 +1,15 @@ +--- + +file: + {{ manala_gomplate_bin }}: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + +command: + {{ manala_gomplate_bin }} --version: + exit-status: 0 + stdout: + - gomplate version diff --git a/molecule/gomplate/goss/version.yml.j2 b/molecule/gomplate/goss/version.yml.j2 new file mode 100644 index 000000000..14de77df3 --- /dev/null +++ b/molecule/gomplate/goss/version.yml.j2 @@ -0,0 +1,17 @@ +--- + +file: + # Fixed + {{ tests_dir }}/fixed: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + +command: + # Fixed + {{ tests_dir }}/fixed --version: + exit-status: 0 + stdout: + - gomplate version 3.8.0 diff --git a/molecule/gomplate/molecule.yml b/molecule/gomplate/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/grafana/converge.yml b/molecule/grafana/converge.yml new file mode 100644 index 000000000..e42af516c --- /dev/null +++ b/molecule/grafana/converge.yml @@ -0,0 +1,111 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.grafana + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/grafana/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Content + import_role: + name: manala.roles.grafana + tasks_from: config + vars: + manala_grafana_config_file: "{{ tests_dir }}/content" + manala_grafana_config_template: ~ + manala_grafana_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.grafana + tasks_from: config + vars: + manala_grafana_config_file: "{{ tests_dir }}/template" + manala_grafana_config_template: fixtures/template.j2 + manala_grafana_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +############### +# Datasources # +############### + +- name: Datasources + tags: [datasources] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.grafana + vars: + manala_grafana_datasources_exclusive: true + manala_grafana_datasources: + - name: datasource_test + type: influxdb + isDefault: true + access: proxy + basicAuth: false + url: http://localhost:8086 + database: telegraf + username: "" + password: "" + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/datasources.yml.j2') }}" + +############## +# Dashboards # +############## + +- name: Dashboards + tags: [dashboards] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.grafana + vars: + manala_grafana_dashboards_exclusive: true + manala_grafana_dashboards: + - template: fixtures/dashboard.json + overwrite: true + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/dashboards.yml.j2') }}" diff --git a/roles/grafana/tests/templates/dashboard_test.json b/molecule/grafana/fixtures/dashboard.json similarity index 100% rename from roles/grafana/tests/templates/dashboard_test.json rename to molecule/grafana/fixtures/dashboard.json diff --git a/molecule/grafana/fixtures/template.j2 b/molecule/grafana/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/grafana/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/grafana/goss/config.yml.j2 b/molecule/grafana/goss/config.yml.j2 new file mode 100644 index 000000000..30ac39316 --- /dev/null +++ b/molecule/grafana/goss/config.yml.j2 @@ -0,0 +1,19 @@ +--- + +file: + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/grafana/goss/dashboards.yml.j2 b/molecule/grafana/goss/dashboards.yml.j2 new file mode 100644 index 000000000..4e3603726 --- /dev/null +++ b/molecule/grafana/goss/dashboards.yml.j2 @@ -0,0 +1,7 @@ +--- + +http: + http://admin:admin@127.0.0.1:3000/api/search: + status: 200 + timeout: 1000 + body: ["dashboard_test"] diff --git a/molecule/grafana/goss/datasources.yml.j2 b/molecule/grafana/goss/datasources.yml.j2 new file mode 100644 index 000000000..297419e53 --- /dev/null +++ b/molecule/grafana/goss/datasources.yml.j2 @@ -0,0 +1,7 @@ +--- + +http: + http://admin:admin@127.0.0.1:3000/api/datasources: + status: 200 + timeout: 1000 + body: ["datasource_test"] diff --git a/molecule/grafana/goss/default.yml.j2 b/molecule/grafana/goss/default.yml.j2 new file mode 100644 index 000000000..8db52e390 --- /dev/null +++ b/molecule/grafana/goss/default.yml.j2 @@ -0,0 +1,20 @@ +--- + +package: + grafana: + installed: true + +service: + grafana-server: + enabled: true + running: true + +process: + grafana-server: + running: true + +port: + tcp6:3000: + listening: true + ip: + - '::' diff --git a/molecule/grafana/molecule.yml b/molecule/grafana/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/grafana/prepare.yml b/molecule/grafana/prepare.yml new file mode 100644 index 000000000..5007cc95e --- /dev/null +++ b/molecule/grafana/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - grafana@grafana diff --git a/molecule/haproxy/converge.yml b/molecule/haproxy/converge.yml new file mode 100644 index 000000000..3bc42bb2b --- /dev/null +++ b/molecule/haproxy/converge.yml @@ -0,0 +1,287 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.haproxy + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +############## +# Errorfiles # +############## + +- name: Errorfiles + tags: [errorfiles] + hosts: debian + vars: + tests_dir: /molecule/haproxy/errorfiles + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.haproxy + tasks_from: errorfiles + vars: + manala_haproxy_errorfiles_exclusive: false + manala_haproxy_errorfiles_dir: "{{ tests_dir }}/default" + manala_haproxy_errorfiles_defaults: {} + manala_haproxy_errorfiles: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.haproxy + tasks_from: errorfiles + vars: + manala_haproxy_errorfiles_exclusive: false + manala_haproxy_errorfiles_dir: "{{ tests_dir }}/defaults" + manala_haproxy_errorfiles_defaults: + template: fixtures/template.j2 + manala_haproxy_errorfiles: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.haproxy + tasks_from: errorfiles + vars: + manala_haproxy_errorfiles_exclusive: true + manala_haproxy_errorfiles_dir: "{{ tests_dir }}/exclusive" + manala_haproxy_errorfiles_defaults: {} + manala_haproxy_errorfiles: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/errorfiles.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/haproxy/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Content + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.haproxy + vars: + manala_haproxy_config_file: "{{ tests_dir }}/content" + manala_haproxy_config_template: ~ + manala_haproxy_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.haproxy + tasks_from: config + vars: + manala_haproxy_config_file: "{{ tests_dir }}/template" + manala_haproxy_config_template: fixtures/template.j2 + manala_haproxy_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/haproxy/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.haproxy + tasks_from: configs + vars: + manala_haproxy_configs_exclusive: false + manala_haproxy_configs_dir: "{{ tests_dir }}/default" + manala_haproxy_configs_defaults: {} + manala_haproxy_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.haproxy + tasks_from: configs + vars: + manala_haproxy_configs_exclusive: false + manala_haproxy_configs_dir: "{{ tests_dir }}/defaults" + manala_haproxy_configs_defaults: + template: fixtures/template.j2 + manala_haproxy_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.haproxy + tasks_from: configs + vars: + manala_haproxy_configs_exclusive: true + manala_haproxy_configs_dir: "{{ tests_dir }}/exclusive" + manala_haproxy_configs_defaults: {} + manala_haproxy_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" + +############### +# Environment # +############### + +- name: Environment + tags: [environment] + hosts: debian + vars: + tests_dir: /molecule/haproxy/environment + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.haproxy + vars: + manala_haproxy_environment_file: "{{ tests_dir }}/dict" + manala_haproxy_environment_template: ~ + manala_haproxy_environment: + CONFIG: /etc/haproxy/conf.d.test + FOO: bar + - name: Role - Content + import_role: + name: manala.roles.haproxy + tasks_from: environment + vars: + manala_haproxy_environment_file: "{{ tests_dir }}/content" + manala_haproxy_environment_template: ~ + manala_haproxy_environment: | + Content + - name: Role - Template + import_role: + name: manala.roles.haproxy + tasks_from: environment + vars: + manala_haproxy_environment_file: "{{ tests_dir }}/template" + manala_haproxy_environment_template: fixtures/template.j2 + manala_haproxy_environment: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/environment.yml.j2') }}" diff --git a/molecule/haproxy/fixtures/template.j2 b/molecule/haproxy/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/haproxy/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/haproxy/fixtures/template_file.j2 b/molecule/haproxy/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/haproxy/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/haproxy/goss/config.yml.j2 b/molecule/haproxy/goss/config.yml.j2 new file mode 100644 index 000000000..30ac39316 --- /dev/null +++ b/molecule/haproxy/goss/config.yml.j2 @@ -0,0 +1,19 @@ +--- + +file: + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/haproxy/goss/configs.yml.j2 b/molecule/haproxy/goss/configs.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/haproxy/goss/configs.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/roles/haproxy/tests/0000_default.goss.yml b/molecule/haproxy/goss/default.yml.j2 similarity index 100% rename from roles/haproxy/tests/0000_default.goss.yml rename to molecule/haproxy/goss/default.yml.j2 diff --git a/molecule/haproxy/goss/environment.yml.j2 b/molecule/haproxy/goss/environment.yml.j2 new file mode 100644 index 000000000..c4231ad3c --- /dev/null +++ b/molecule/haproxy/goss/environment.yml.j2 @@ -0,0 +1,28 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^CONFIG=\"/etc/haproxy/conf.d.test\"$/" + - "/^FOO=\"bar\"$/" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/haproxy/goss/errorfiles.yml.j2 b/molecule/haproxy/goss/errorfiles.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/haproxy/goss/errorfiles.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/haproxy/molecule.yml b/molecule/haproxy/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/haproxy/prepare.yml b/molecule/haproxy/prepare.yml new file mode 100644 index 000000000..709afeb0f --- /dev/null +++ b/molecule/haproxy/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - haproxy@backports diff --git a/molecule/influxdb/converge.yml b/molecule/influxdb/converge.yml new file mode 100644 index 000000000..4d9a60bb2 --- /dev/null +++ b/molecule/influxdb/converge.yml @@ -0,0 +1,89 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + vars: + tests_dir: /molecule/influxdb/default + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + name: manala.roles.influxdb + vars: + manala_influxdb_dir: + - "{{ tests_dir }}/meta" + - "{{ tests_dir }}/data" + - "{{ tests_dir }}/wal" + manala_influxdb_databases: + - my_db + manala_influxdb_users: + - database: my_db + name: my_user + password: my_password + manala_influxdb_privileges: + - database: my_db + user: my_user + grant: ALL + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/influxdb/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.influxdb + vars: + manala_influxdb_config_file: "{{ tests_dir }}/dict" + manala_influxdb_config_template: ~ + manala_influxdb_config: + reporting-disabled: true + - name: Role - Content + import_role: + name: manala.roles.influxdb + tasks_from: config + vars: + manala_influxdb_config_file: "{{ tests_dir }}/content" + manala_influxdb_config_template: ~ + manala_influxdb_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.influxdb + tasks_from: config + vars: + manala_influxdb_config_file: "{{ tests_dir }}/template" + manala_influxdb_config_template: fixtures/template.j2 + manala_influxdb_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" diff --git a/molecule/influxdb/fixtures/template.j2 b/molecule/influxdb/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/influxdb/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/influxdb/goss/config.yml.j2 b/molecule/influxdb/goss/config.yml.j2 new file mode 100644 index 000000000..322b324d8 --- /dev/null +++ b/molecule/influxdb/goss/config.yml.j2 @@ -0,0 +1,27 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - reporting-disabled = true + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/influxdb/goss/default.yml.j2 b/molecule/influxdb/goss/default.yml.j2 new file mode 100644 index 000000000..65f2927d1 --- /dev/null +++ b/molecule/influxdb/goss/default.yml.j2 @@ -0,0 +1,44 @@ +--- + +package: + influxdb: + installed: true + +service: + influxdb: + enabled: true + running: true + +file: + {{ tests_dir }}/data: + exists: true + filetype: directory + owner: influxdb + group: influxdb + mode: "0750" + {{ tests_dir }}/meta: + exists: true + filetype: directory + owner: influxdb + group: influxdb + mode: "0750" + {{ tests_dir }}/wal: + exists: true + filetype: directory + owner: influxdb + group: influxdb + mode: "0750" + +command: + influx -execute 'show databases': + exit-status: 0 + stdout: + - my_db + influx -execute 'show users': + exit-status: 0 + stdout: + - my_user + influx -database my_db -execute 'show grants for my_user': + exit-status: 0 + stdout: + - my_db ALL PRIVILEGES diff --git a/molecule/influxdb/molecule.yml b/molecule/influxdb/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/influxdb/prepare.yml b/molecule/influxdb/prepare.yml new file mode 100644 index 000000000..0296ae2d4 --- /dev/null +++ b/molecule/influxdb/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - influxdb@influxdata diff --git a/molecule/java/converge.yml b/molecule/java/converge.yml new file mode 100644 index 000000000..672560e71 --- /dev/null +++ b/molecule/java/converge.yml @@ -0,0 +1,19 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.java + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/java/goss/default.yml.j2 b/molecule/java/goss/default.yml.j2 new file mode 100644 index 000000000..5f04e8d64 --- /dev/null +++ b/molecule/java/goss/default.yml.j2 @@ -0,0 +1,5 @@ +command: + java -version: + exit-status: 0 + stderr: + - "/^openjdk version/" diff --git a/molecule/java/molecule.yml b/molecule/java/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/keepalived/converge.yml b/molecule/keepalived/converge.yml new file mode 100644 index 000000000..802fcbfdb --- /dev/null +++ b/molecule/keepalived/converge.yml @@ -0,0 +1,112 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.keepalived + vars: + manala_keepalived_config: | + global_defs { + router_id LVS_DEVEL + } + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/keepalived/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Content + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.keepalived + vars: + manala_keepalived_config_file: "{{ tests_dir }}/content" + manala_keepalived_config_template: ~ + manala_keepalived_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.keepalived + tasks_from: config + vars: + manala_keepalived_config_file: "{{ tests_dir }}/template" + manala_keepalived_config_template: fixtures/template.j2 + manala_keepalived_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +############### +# Environment # +############### + +- name: Environment + tags: [environment] + hosts: debian + vars: + tests_dir: /molecule/keepalived/environment + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.keepalived + vars: + manala_keepalived_environment_file: "{{ tests_dir }}/dict" + manala_keepalived_environment_template: ~ + manala_keepalived_environment: + DAEMON_ARGS: --log-console --log-detail + FOO: bar + - name: Role - Content + import_role: + name: manala.roles.keepalived + tasks_from: environment + vars: + manala_keepalived_environment_file: "{{ tests_dir }}/content" + manala_keepalived_environment_template: ~ + manala_keepalived_environment: | + Content + - name: Role - Template + import_role: + name: manala.roles.keepalived + tasks_from: environment + vars: + manala_keepalived_environment_file: "{{ tests_dir }}/template" + manala_keepalived_environment_template: fixtures/template.j2 + manala_keepalived_environment: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/environment.yml.j2') }}" diff --git a/molecule/keepalived/fixtures/template.j2 b/molecule/keepalived/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/keepalived/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/keepalived/goss/config.yml.j2 b/molecule/keepalived/goss/config.yml.j2 new file mode 100644 index 000000000..30ac39316 --- /dev/null +++ b/molecule/keepalived/goss/config.yml.j2 @@ -0,0 +1,19 @@ +--- + +file: + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/roles/keepalived/tests/0000_default.goss.yml b/molecule/keepalived/goss/default.yml.j2 similarity index 100% rename from roles/keepalived/tests/0000_default.goss.yml rename to molecule/keepalived/goss/default.yml.j2 diff --git a/molecule/keepalived/goss/environment.yml.j2 b/molecule/keepalived/goss/environment.yml.j2 new file mode 100644 index 000000000..c92bea693 --- /dev/null +++ b/molecule/keepalived/goss/environment.yml.j2 @@ -0,0 +1,28 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^DAEMON_ARGS=\"--log-console --log-detail\"$/" + - "/^FOO=\"bar\"$/" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/keepalived/molecule.yml b/molecule/keepalived/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/kernel/converge.yml b/molecule/kernel/converge.yml new file mode 100644 index 000000000..ee9ebc410 --- /dev/null +++ b/molecule/kernel/converge.yml @@ -0,0 +1,23 @@ +--- + +############## +# Parameters # +############## + +- name: Parameters + tags: [parameters] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.kernel + vars: + manala_kernel_parameters: + - parameter: net.ipv4.ip_nonlocal_bind + value: 3 + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/parameters.yml.j2') }}" diff --git a/roles/kernel/tests/0200_parameters.goss.yml b/molecule/kernel/goss/parameters.yml.j2 similarity index 100% rename from roles/kernel/tests/0200_parameters.goss.yml rename to molecule/kernel/goss/parameters.yml.j2 diff --git a/molecule/kernel/molecule.yml b/molecule/kernel/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/locales/converge.yml b/molecule/locales/converge.yml new file mode 100644 index 000000000..9966bb052 --- /dev/null +++ b/molecule/locales/converge.yml @@ -0,0 +1,92 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.locales + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +######### +# Codes # +######### + +- name: Codes - Codes + tags: [codes, codes.codes] + hosts: debian + tasks: + - block: + - name: Role - 1 + import_role: + name: manala.roles.locales + vars: + manala_locales_codes: + # With charmap + - fr_FR.UTF-8 + - code: en_DK.UTF-8 + state: present + - code: en_DK.ISO-8859-15 + state: present + - code: hu_HU.UTF-8 + state: absent + - code: hy_AM.ARMSCII-8 + state: absent + # Without charmap + - ru_RU + - code: ve_ZA + state: present + - code: vi_VN + state: present + - code: th_TH + state: absent + - code: the_NP + state: absent + - name: Role - 2 + import_role: + name: manala.roles.locales + vars: + manala_locales_codes: + # With charmap + - code: en_DK.ISO-8859-15 + state: absent + - code: hy_AM.ARMSCII-8 + state: present + # Without charmap + - code: vi_VN + state: absent + - code: the_NP + state: present + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/codes_codes.yml.j2') }}" + +- name: Codes - Default + tags: [codes, codes.default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.locales + vars: + manala_locales_codes: + - fr_FR.UTF-8 + manala_locales_codes_default: fr_FR.UTF-8 + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/codes_default.yml.j2') }}" diff --git a/molecule/locales/goss/codes_codes.yml.j2 b/molecule/locales/goss/codes_codes.yml.j2 new file mode 100644 index 000000000..bcb1fc64d --- /dev/null +++ b/molecule/locales/goss/codes_codes.yml.j2 @@ -0,0 +1,16 @@ +--- + +command: + locale --all-locales: + exit-status: 0 + stdout: + - "/^fr_FR.utf8$/" + - "/^en_DK.utf8$/" + - "!/^en_DK.iso885915$/" + - "!/^hu_HU.utf8$/" + - "/^hy_AM.armscii8$/" + - "/^ru_RU$/" + - "/^ve_ZA$/" + - "!/^vi_VN$/" + - "!/^th_TH$/" + - "/^the_NP$/" diff --git a/roles/locales/tests/0300_codes_default.goss.yml b/molecule/locales/goss/codes_default.yml.j2 similarity index 100% rename from roles/locales/tests/0300_codes_default.goss.yml rename to molecule/locales/goss/codes_default.yml.j2 diff --git a/roles/locales/tests/0100_install.goss.yml b/molecule/locales/goss/default.yml.j2 similarity index 100% rename from roles/locales/tests/0100_install.goss.yml rename to molecule/locales/goss/default.yml.j2 diff --git a/molecule/locales/molecule.yml b/molecule/locales/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/logrotate/converge.yml b/molecule/logrotate/converge.yml new file mode 100644 index 000000000..0588e01cc --- /dev/null +++ b/molecule/logrotate/converge.yml @@ -0,0 +1,115 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.logrotate + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/logrotate/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.logrotate + tasks_from: configs + vars: + manala_logrotate_configs_exclusive: false + manala_logrotate_configs_dir: "{{ tests_dir }}/default" + manala_logrotate_configs_defaults: {} + manala_logrotate_configs: + # Dict + - file: dict + config: + /var/log/foo/*.log: + rotate: 17 + weekly: true + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.logrotate + tasks_from: configs + vars: + manala_logrotate_configs_exclusive: false + manala_logrotate_configs_dir: "{{ tests_dir }}/defaults" + manala_logrotate_configs_defaults: + template: fixtures/template.j2 + manala_logrotate_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.logrotate + tasks_from: configs + vars: + manala_logrotate_configs_exclusive: true + manala_logrotate_configs_dir: "{{ tests_dir }}/exclusive" + manala_logrotate_configs_defaults: {} + manala_logrotate_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" diff --git a/molecule/logrotate/fixtures/template.j2 b/molecule/logrotate/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/logrotate/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/logrotate/fixtures/template_file.j2 b/molecule/logrotate/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/logrotate/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/logrotate/goss/configs.yml.j2 b/molecule/logrotate/goss/configs.yml.j2 new file mode 100644 index 000000000..fec97ebbc --- /dev/null +++ b/molecule/logrotate/goss/configs.yml.j2 @@ -0,0 +1,111 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/var/log/foo/*.log {" + - " rotate 17" + - " weekly" + - "}" + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/roles/logrotate/tests/0000_default.goss.yml b/molecule/logrotate/goss/default.yml.j2 similarity index 100% rename from roles/logrotate/tests/0000_default.goss.yml rename to molecule/logrotate/goss/default.yml.j2 diff --git a/molecule/logrotate/molecule.yml b/molecule/logrotate/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/make/converge.yml b/molecule/make/converge.yml new file mode 100644 index 000000000..8378a6043 --- /dev/null +++ b/molecule/make/converge.yml @@ -0,0 +1,19 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.make + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/make/tests/0100_install.goss.yml b/molecule/make/goss/default.yml.j2 similarity index 100% rename from roles/make/tests/0100_install.goss.yml rename to molecule/make/goss/default.yml.j2 diff --git a/molecule/make/molecule.yml b/molecule/make/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/maxscale.2.2/converge.yml b/molecule/maxscale.2.2/converge.yml new file mode 100644 index 000000000..5402bbe27 --- /dev/null +++ b/molecule/maxscale.2.2/converge.yml @@ -0,0 +1,15 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + tasks: + - block: + - name: Role + import_role: + name: manala.roles.maxscale diff --git a/molecule/maxscale.2.2/goss/default.yml.j2 b/molecule/maxscale.2.2/goss/default.yml.j2 new file mode 100644 index 000000000..5ca6a6291 --- /dev/null +++ b/molecule/maxscale.2.2/goss/default.yml.j2 @@ -0,0 +1,28 @@ +--- + +package: + maxscale: + installed: true + +command: + maxscale --version: + exit-status: 0 + stdout: + - "/^MaxScale 2.2.\\d+$/" + maxadmin show users: + exit-status: 0 + stdout: + - "/^Enabled Linux accounts \\(secure\\) : root$/" + - "/^Created network accounts \\(insecure\\): admin$/" + +file: + /var/lib/maxscale/passwd: + exists: true + filetype: file + contains: + - '[{"name": "admin", "account": "admin", "password": "$1$MXS$ZKZ/yMdf0ycX3d18iuS9U."}]' + +service: + maxscale: + enabled: true + running: true diff --git a/molecule/maxscale.2.2/molecule.yml b/molecule/maxscale.2.2/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/maxscale.2.2/prepare.yml b/molecule/maxscale.2.2/prepare.yml new file mode 100644 index 000000000..3c9ae71a5 --- /dev/null +++ b/molecule/maxscale.2.2/prepare.yml @@ -0,0 +1,12 @@ +--- + +- hosts: + - debian.stretch + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - maxscale@maxscale_2_2 diff --git a/molecule/maxscale.2.3/converge.yml b/molecule/maxscale.2.3/converge.yml new file mode 100644 index 000000000..197bcdabc --- /dev/null +++ b/molecule/maxscale.2.3/converge.yml @@ -0,0 +1,21 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.maxscale + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/maxscale.2.3/goss/default.yml.j2 b/molecule/maxscale.2.3/goss/default.yml.j2 new file mode 100644 index 000000000..6a946e287 --- /dev/null +++ b/molecule/maxscale.2.3/goss/default.yml.j2 @@ -0,0 +1,28 @@ +--- + +package: + maxscale: + installed: true + +command: + maxscale --version: + exit-status: 0 + stdout: + - "/^MaxScale 2.3.\\d+$/" + maxadmin show users: + exit-status: 0 + stdout: + - "/^Enabled Linux accounts \\(secure\\) : root$/" + - "/^Created network accounts \\(insecure\\): admin$/" + +file: + /var/lib/maxscale/passwd: + exists: true + filetype: file + contains: + - '[{"name": "admin", "account": "admin", "password": "$1$MXS$ZKZ/yMdf0ycX3d18iuS9U."}]' + +service: + maxscale: + enabled: true + running: true diff --git a/molecule/maxscale.2.3/molecule.yml b/molecule/maxscale.2.3/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/maxscale.2.3/prepare.yml b/molecule/maxscale.2.3/prepare.yml new file mode 100644 index 000000000..5ff159223 --- /dev/null +++ b/molecule/maxscale.2.3/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - maxscale@maxscale_2_3 diff --git a/molecule/maxscale.2.4/converge.yml b/molecule/maxscale.2.4/converge.yml new file mode 100644 index 000000000..197bcdabc --- /dev/null +++ b/molecule/maxscale.2.4/converge.yml @@ -0,0 +1,21 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.maxscale + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/maxscale.2.4/goss/default.yml.j2 b/molecule/maxscale.2.4/goss/default.yml.j2 new file mode 100644 index 000000000..936700264 --- /dev/null +++ b/molecule/maxscale.2.4/goss/default.yml.j2 @@ -0,0 +1,28 @@ +--- + +package: + maxscale: + installed: true + +command: + maxscale --version: + exit-status: 0 + stdout: + - "/^MaxScale 2.4.\\d+$/" + maxctrl list users: + exit-status: 0 + stdout: + - "/^│ admin │ inet │ admin │$/" + - "/^│ root │ unix │ admin │$/" + +file: + /var/lib/maxscale/passwd: + exists: true + filetype: file + contains: + - '[{"name": "admin", "account": "admin", "password": "$6$MXS$RjtL0yWoXRIzkDGR6iwIAUHrQTWvqMizWYaGZKetqP2VDmWLgpgaT5YueeBoMKkoTMisvIy3sGEUMFa16UYDc."}]' + +service: + maxscale: + enabled: true + running: true diff --git a/molecule/maxscale.2.4/molecule.yml b/molecule/maxscale.2.4/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/maxscale.2.4/prepare.yml b/molecule/maxscale.2.4/prepare.yml new file mode 100644 index 000000000..ba1fc2982 --- /dev/null +++ b/molecule/maxscale.2.4/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - maxscale@maxscale_2_4 diff --git a/molecule/maxscale.2.5/converge.yml b/molecule/maxscale.2.5/converge.yml new file mode 100644 index 000000000..ba6f4f7a3 --- /dev/null +++ b/molecule/maxscale.2.5/converge.yml @@ -0,0 +1,206 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.maxscale + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: + - debian.stretch + - debian.buster + vars: + tests_dir: /molecule/maxscale/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Content + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.maxscale + vars: + manala_maxscale_config_file: "{{ tests_dir }}/content" + manala_maxscale_config_template: ~ + manala_maxscale_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.maxscale + tasks_from: config + vars: + manala_maxscale_config_file: "{{ tests_dir }}/template" + manala_maxscale_config_template: fixtures/template.j2 + manala_maxscale_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: + - debian.stretch + - debian.buster + vars: + tests_dir: /molecule/maxscale/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.maxscale + tasks_from: configs + vars: + manala_maxscale_configs_exclusive: false + manala_maxscale_configs_dir: "{{ tests_dir }}/default" + manala_maxscale_configs_defaults: {} + manala_maxscale_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.maxscale + tasks_from: configs + vars: + manala_maxscale_configs_exclusive: false + manala_maxscale_configs_dir: "{{ tests_dir }}/defaults" + manala_maxscale_configs_defaults: + template: fixtures/template.j2 + manala_maxscale_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.maxscale + tasks_from: configs + vars: + manala_maxscale_configs_exclusive: true + manala_maxscale_configs_dir: "{{ tests_dir }}/exclusive" + manala_maxscale_configs_defaults: {} + manala_maxscale_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" + +######### +# Users # +######### + +- name: Users + tags: [users] + hosts: + - debian.stretch + - debian.buster + vars: + tests_dir: /molecule/maxscale/users + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Array + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.maxscale + vars: + manala_maxscale_users_file: "{{ tests_dir }}/array" + manala_maxscale_users_template: ~ + manala_maxscale_network_users: + - name: foo + password: $1$MXS$ilOCSZPnjmHjTz6B96SiJ1 # "foo" + - name: bar + password: $1$MXS$M.YZOr2pNTgW87l7KQWLU/ # "bar" + - name: Role - Array Empty + import_role: + name: manala.roles.maxscale + tasks_from: users + vars: + manala_maxscale_users_file: "{{ tests_dir }}/array_empty" + manala_maxscale_users_template: ~ + manala_maxscale_network_users: [] + - name: Role - Template + import_role: + name: manala.roles.maxscale + tasks_from: users + vars: + manala_maxscale_users_file: "{{ tests_dir }}/template" + manala_maxscale_users_template: fixtures/template.j2 + manala_maxscale_network_users: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/users.yml.j2') }}" diff --git a/molecule/maxscale.2.5/fixtures/template.j2 b/molecule/maxscale.2.5/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/maxscale.2.5/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/maxscale.2.5/fixtures/template_file.j2 b/molecule/maxscale.2.5/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/maxscale.2.5/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/maxscale.2.5/goss/config.yml.j2 b/molecule/maxscale.2.5/goss/config.yml.j2 new file mode 100644 index 000000000..30ac39316 --- /dev/null +++ b/molecule/maxscale.2.5/goss/config.yml.j2 @@ -0,0 +1,19 @@ +--- + +file: + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/maxscale.2.5/goss/configs.yml.j2 b/molecule/maxscale.2.5/goss/configs.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/maxscale.2.5/goss/configs.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/maxscale.2.5/goss/default.yml.j2 b/molecule/maxscale.2.5/goss/default.yml.j2 new file mode 100644 index 000000000..a13163dd7 --- /dev/null +++ b/molecule/maxscale.2.5/goss/default.yml.j2 @@ -0,0 +1,27 @@ +--- + +package: + maxscale: + installed: true + +command: + maxscale --version: + exit-status: 0 + stdout: + - "/^MaxScale 2.5.\\d+$/" + maxctrl list users: + exit-status: 0 + stdout: + - "/^│ admin │ inet │ admin │$/" + +file: + /var/lib/maxscale/passwd: + exists: true + filetype: file + contains: + - '[{"name": "admin", "account": "admin", "password": "$6$MXS$RjtL0yWoXRIzkDGR6iwIAUHrQTWvqMizWYaGZKetqP2VDmWLgpgaT5YueeBoMKkoTMisvIy3sGEUMFa16UYDc."}]' + +service: + maxscale: + enabled: true + running: true diff --git a/molecule/maxscale.2.5/goss/users.yml.j2 b/molecule/maxscale.2.5/goss/users.yml.j2 new file mode 100644 index 000000000..46994d9fb --- /dev/null +++ b/molecule/maxscale.2.5/goss/users.yml.j2 @@ -0,0 +1,28 @@ +--- + +file: + {{ tests_dir }}/array: + exists: true + filetype: file + owner: maxscale + group: maxscale + mode: "0600" + contains: + - '[{"account": "admin", "name": "foo", "password": "$1$MXS$ilOCSZPnjmHjTz6B96SiJ1"},{"account": "admin", "name": "bar", "password": "$1$MXS$M.YZOr2pNTgW87l7KQWLU/"}]' + {{ tests_dir }}/array_empty: + exists: true + filetype: file + owner: maxscale + group: maxscale + mode: "0600" + size: 2 + contains: + - '[]' + {{ tests_dir }}/template: + exists: true + filetype: file + owner: maxscale + group: maxscale + mode: "0600" + contains: + - "/^Template$/" diff --git a/molecule/maxscale.2.5/molecule.yml b/molecule/maxscale.2.5/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/maxscale.2.5/prepare.yml b/molecule/maxscale.2.5/prepare.yml new file mode 100644 index 000000000..77321e297 --- /dev/null +++ b/molecule/maxscale.2.5/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - maxscale@maxscale_2_5 diff --git a/molecule/maxscale.6.1/converge.yml b/molecule/maxscale.6.1/converge.yml new file mode 100644 index 000000000..de6f46dae --- /dev/null +++ b/molecule/maxscale.6.1/converge.yml @@ -0,0 +1,198 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.maxscale + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/maxscale/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Content + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.maxscale + vars: + manala_maxscale_config_file: "{{ tests_dir }}/content" + manala_maxscale_config_template: ~ + manala_maxscale_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.maxscale + tasks_from: config + vars: + manala_maxscale_config_file: "{{ tests_dir }}/template" + manala_maxscale_config_template: fixtures/template.j2 + manala_maxscale_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/maxscale/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.maxscale + tasks_from: configs + vars: + manala_maxscale_configs_exclusive: false + manala_maxscale_configs_dir: "{{ tests_dir }}/default" + manala_maxscale_configs_defaults: {} + manala_maxscale_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.maxscale + tasks_from: configs + vars: + manala_maxscale_configs_exclusive: false + manala_maxscale_configs_dir: "{{ tests_dir }}/defaults" + manala_maxscale_configs_defaults: + template: fixtures/template.j2 + manala_maxscale_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.maxscale + tasks_from: configs + vars: + manala_maxscale_configs_exclusive: true + manala_maxscale_configs_dir: "{{ tests_dir }}/exclusive" + manala_maxscale_configs_defaults: {} + manala_maxscale_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" + +######### +# Users # +######### + +- name: Users + tags: [users] + hosts: debian + vars: + tests_dir: /molecule/maxscale/users + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Array + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.maxscale + vars: + manala_maxscale_users_file: "{{ tests_dir }}/array" + manala_maxscale_users_template: ~ + manala_maxscale_network_users: + - name: foo + password: $1$MXS$ilOCSZPnjmHjTz6B96SiJ1 # "foo" + - name: bar + password: $1$MXS$M.YZOr2pNTgW87l7KQWLU/ # "bar" + - name: Role - Array Empty + import_role: + name: manala.roles.maxscale + tasks_from: users + vars: + manala_maxscale_users_file: "{{ tests_dir }}/array_empty" + manala_maxscale_users_template: ~ + manala_maxscale_network_users: [] + - name: Role - Template + import_role: + name: manala.roles.maxscale + tasks_from: users + vars: + manala_maxscale_users_file: "{{ tests_dir }}/template" + manala_maxscale_users_template: fixtures/template.j2 + manala_maxscale_network_users: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/users.yml.j2') }}" diff --git a/molecule/maxscale.6.1/fixtures/template.j2 b/molecule/maxscale.6.1/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/maxscale.6.1/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/maxscale.6.1/fixtures/template_file.j2 b/molecule/maxscale.6.1/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/maxscale.6.1/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/maxscale.6.1/goss/config.yml.j2 b/molecule/maxscale.6.1/goss/config.yml.j2 new file mode 100644 index 000000000..30ac39316 --- /dev/null +++ b/molecule/maxscale.6.1/goss/config.yml.j2 @@ -0,0 +1,19 @@ +--- + +file: + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/maxscale.6.1/goss/configs.yml.j2 b/molecule/maxscale.6.1/goss/configs.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/maxscale.6.1/goss/configs.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/maxscale.6.1/goss/default.yml.j2 b/molecule/maxscale.6.1/goss/default.yml.j2 new file mode 100644 index 000000000..384fd92f5 --- /dev/null +++ b/molecule/maxscale.6.1/goss/default.yml.j2 @@ -0,0 +1,27 @@ +--- + +package: + maxscale: + installed: true + +command: + maxscale --version: + exit-status: 0 + stdout: + - "/^MaxScale 6.1.\\d+$/" + maxctrl list users: + exit-status: 0 + stdout: + - "/^│ admin │ inet │ admin │$/" + +file: + /var/lib/maxscale/passwd: + exists: true + filetype: file + contains: + - '[{"name": "admin", "account": "admin", "password": "$6$MXS$RjtL0yWoXRIzkDGR6iwIAUHrQTWvqMizWYaGZKetqP2VDmWLgpgaT5YueeBoMKkoTMisvIy3sGEUMFa16UYDc."}]' + +service: + maxscale: + enabled: true + running: true diff --git a/molecule/maxscale.6.1/goss/users.yml.j2 b/molecule/maxscale.6.1/goss/users.yml.j2 new file mode 100644 index 000000000..46994d9fb --- /dev/null +++ b/molecule/maxscale.6.1/goss/users.yml.j2 @@ -0,0 +1,28 @@ +--- + +file: + {{ tests_dir }}/array: + exists: true + filetype: file + owner: maxscale + group: maxscale + mode: "0600" + contains: + - '[{"account": "admin", "name": "foo", "password": "$1$MXS$ilOCSZPnjmHjTz6B96SiJ1"},{"account": "admin", "name": "bar", "password": "$1$MXS$M.YZOr2pNTgW87l7KQWLU/"}]' + {{ tests_dir }}/array_empty: + exists: true + filetype: file + owner: maxscale + group: maxscale + mode: "0600" + size: 2 + contains: + - '[]' + {{ tests_dir }}/template: + exists: true + filetype: file + owner: maxscale + group: maxscale + mode: "0600" + contains: + - "/^Template$/" diff --git a/molecule/maxscale.6.1/molecule.yml b/molecule/maxscale.6.1/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/maxscale.6.1/prepare.yml b/molecule/maxscale.6.1/prepare.yml new file mode 100644 index 000000000..149627ab0 --- /dev/null +++ b/molecule/maxscale.6.1/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - maxscale@maxscale_6_1 diff --git a/molecule/mongodb.3.6/converge.yml b/molecule/mongodb.3.6/converge.yml new file mode 100644 index 000000000..1c749fe05 --- /dev/null +++ b/molecule/mongodb.3.6/converge.yml @@ -0,0 +1,69 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + tasks: + - block: + - name: Role + import_role: + name: manala.roles.mongodb + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: + - debian.stretch + vars: + tests_dir: /molecule/mongodb/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.mongodb + vars: + manala_mongodb_config_file: "{{ tests_dir }}/dict" + manala_mongodb_config_template: ~ + manala_mongodb_config: + port: 12345 + - name: Role - Content + import_role: + name: manala.roles.mongodb + tasks_from: config + vars: + manala_mongodb_config_file: "{{ tests_dir }}/content" + manala_mongodb_config_template: ~ + manala_mongodb_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.mongodb + tasks_from: config + vars: + manala_mongodb_config_file: "{{ tests_dir }}/template" + manala_mongodb_config_template: fixtures/template.j2 + manala_mongodb_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" diff --git a/molecule/mongodb.3.6/fixtures/template.j2 b/molecule/mongodb.3.6/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/mongodb.3.6/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/mongodb.3.6/goss/config.yml.j2 b/molecule/mongodb.3.6/goss/config.yml.j2 new file mode 100644 index 000000000..df1376383 --- /dev/null +++ b/molecule/mongodb.3.6/goss/config.yml.j2 @@ -0,0 +1,27 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "port: 12345" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/roles/mongodb/tests/0000_default.3.6.goss.yml b/molecule/mongodb.3.6/goss/default.yml.j2 similarity index 100% rename from roles/mongodb/tests/0000_default.3.6.goss.yml rename to molecule/mongodb.3.6/goss/default.yml.j2 diff --git a/molecule/mongodb.3.6/molecule.yml b/molecule/mongodb.3.6/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mongodb.3.6/prepare.yml b/molecule/mongodb.3.6/prepare.yml new file mode 100644 index 000000000..91dee1970 --- /dev/null +++ b/molecule/mongodb.3.6/prepare.yml @@ -0,0 +1,12 @@ +--- + +- hosts: + - debian.stretch + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - mongodb@mongodb_3_6 diff --git a/molecule/mongodb.4.4/converge.yml b/molecule/mongodb.4.4/converge.yml new file mode 100644 index 000000000..4f3ff457b --- /dev/null +++ b/molecule/mongodb.4.4/converge.yml @@ -0,0 +1,113 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.mongodb + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: + - debian.stretch + - debian.buster + vars: + tests_dir: /molecule/mongodb/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.mongodb + vars: + manala_mongodb_config_file: "{{ tests_dir }}/dict" + manala_mongodb_config_template: ~ + manala_mongodb_config: + port: 12345 + - name: Role - Content + import_role: + name: manala.roles.mongodb + tasks_from: config + vars: + manala_mongodb_config_file: "{{ tests_dir }}/content" + manala_mongodb_config_template: ~ + manala_mongodb_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.mongodb + tasks_from: config + vars: + manala_mongodb_config_file: "{{ tests_dir }}/template" + manala_mongodb_config_template: fixtures/template.j2 + manala_mongodb_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +######### +# Users # +######### + +- name: Users + tags: [users] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.mongodb + vars: + manala_mongodb_users: + - name: foo + password: foo + database: admin + roles: userAdminAnyDatabase + state: present + - name: bar + password: bar + database: zerty + roles: read + login_database: admin + login_user: dba + login_password: bar + state: ignore + # Flatten + - + - name: baz + password: baz + database: admin + roles: userAdminAnyDatabase + state: present + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/users.yml.j2') }}" diff --git a/molecule/mongodb.4.4/fixtures/template.j2 b/molecule/mongodb.4.4/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/mongodb.4.4/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/mongodb.4.4/goss/config.yml.j2 b/molecule/mongodb.4.4/goss/config.yml.j2 new file mode 100644 index 000000000..df1376383 --- /dev/null +++ b/molecule/mongodb.4.4/goss/config.yml.j2 @@ -0,0 +1,27 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "port: 12345" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/roles/mongodb/tests/0001_default.4.4.goss.yml b/molecule/mongodb.4.4/goss/default.yml.j2 similarity index 100% rename from roles/mongodb/tests/0001_default.4.4.goss.yml rename to molecule/mongodb.4.4/goss/default.yml.j2 diff --git a/roles/mongodb/tests/0301_users.4.4.goss.yml b/molecule/mongodb.4.4/goss/users.yml.j2 similarity index 100% rename from roles/mongodb/tests/0301_users.4.4.goss.yml rename to molecule/mongodb.4.4/goss/users.yml.j2 diff --git a/molecule/mongodb.4.4/molecule.yml b/molecule/mongodb.4.4/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mongodb.4.4/prepare.yml b/molecule/mongodb.4.4/prepare.yml new file mode 100644 index 000000000..083788778 --- /dev/null +++ b/molecule/mongodb.4.4/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - mongodb@mongodb_4_4 diff --git a/molecule/motd/converge.yml b/molecule/motd/converge.yml new file mode 100644 index 000000000..64631b84c --- /dev/null +++ b/molecule/motd/converge.yml @@ -0,0 +1,94 @@ +--- + +########### +# Scripts # +########### + +- name: Scripts + tags: [scripts] + hosts: debian + vars: + tests_dir: /molecule/motd/scripts + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.motd + tasks_from: scripts + vars: + manala_motd_scripts_exclusive: false + manala_motd_scripts_dir: "{{ tests_dir }}/default" + manala_motd_scripts_defaults: {} + manala_motd_scripts: + # Message + - file: message + message: I hope that someone gets my message in a bottle, yeah + # Content + - file: content + script: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.motd + tasks_from: scripts + vars: + manala_motd_scripts_exclusive: false + manala_motd_scripts_dir: "{{ tests_dir }}/defaults" + manala_motd_scripts_defaults: + template: fixtures/template.j2 + manala_motd_scripts: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.motd + tasks_from: scripts + vars: + manala_motd_scripts_exclusive: true + manala_motd_scripts_dir: "{{ tests_dir }}/exclusive" + manala_motd_scripts_defaults: {} + manala_motd_scripts: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/scripts.yml.j2') }}" diff --git a/molecule/motd/fixtures/template.j2 b/molecule/motd/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/motd/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/motd/fixtures/template_file.j2 b/molecule/motd/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/motd/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/motd/goss/scripts.yml.j2 b/molecule/motd/goss/scripts.yml.j2 new file mode 100644 index 000000000..52ff64324 --- /dev/null +++ b/molecule/motd/goss/scripts.yml.j2 @@ -0,0 +1,109 @@ +--- + +file: + + # Default - Message + {{ tests_dir }}/default/message: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + contains: + - "#!/bin/sh" + - "printf \"I hope that someone gets my message in a bottle, yeah\\n\"" + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/motd/molecule.yml b/molecule/motd/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mount/converge.yml b/molecule/mount/converge.yml new file mode 100644 index 000000000..becce6ed1 --- /dev/null +++ b/molecule/mount/converge.yml @@ -0,0 +1,40 @@ +--- + +########## +# Points # +########## + +- name: Points + tags: [points] + hosts: debian + vars: + tests_dir: /molecule/mount/points + tasks: + - name: Directory # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/directory" + state: directory + - name: File # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/directory/file" + state: touch + - block: + - name: Role + import_role: + name: manala.roles.mount + tasks_from: points + vars: + manala_mount_points: + - path: "{{ tests_dir }}/ignore" + state: ignore + # Flatten + - + - path: "{{ tests_dir }}/bind" + src: "{{ tests_dir }}/directory" + fstype: none + opts: bind + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/points.yml.j2') }}" diff --git a/molecule/mount/goss/points.yml.j2 b/molecule/mount/goss/points.yml.j2 new file mode 100644 index 000000000..b2b98d933 --- /dev/null +++ b/molecule/mount/goss/points.yml.j2 @@ -0,0 +1,8 @@ +--- + +file: + {{ tests_dir }}/ignore: + exists: false + {{ tests_dir }}/directory/file: + exists: true + filetype: file diff --git a/molecule/mount/molecule.yml b/molecule/mount/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mysql.5.6/converge.yml b/molecule/mysql.5.6/converge.yml new file mode 100644 index 000000000..f47d6d57a --- /dev/null +++ b/molecule/mysql.5.6/converge.yml @@ -0,0 +1,41 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + tasks: + - block: + - name: Role + import_role: + name: manala.roles.mysql + vars: + manala_mysql_users: + - name: foo + password: foo + host: localhost + priv: "*.*:ALL,GRANT" + - name: bar + state: ignore + # Flatten + - + - name: baz + password: baz + host: localhost + priv: "*.*:ALL,GRANT" + manala_mysql_databases: + - name: foo + - name: bar + state: ignore + # Flatten + - + - name: baz + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/mysql.5.6/goss/default.yml.j2 b/molecule/mysql.5.6/goss/default.yml.j2 new file mode 100644 index 000000000..4b3c3c2d6 --- /dev/null +++ b/molecule/mysql.5.6/goss/default.yml.j2 @@ -0,0 +1,38 @@ +--- + +package: + mysql-server: + installed: true + mysql-client: + installed: true + +command: + mysql --version: + exit-status: 0 + stdout: + - "/mysql(.)*Distrib 5.6/" + mysql -u root --execute "select user from mysql.user": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + mysqladmin --user=foo --password=foo ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysqladmin --user=baz --password=baz ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysql -u root --execute "show databases": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + +service: + mysql: + enabled: true + running: true diff --git a/molecule/mysql.5.6/molecule.yml b/molecule/mysql.5.6/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mysql.5.6/prepare.yml b/molecule/mysql.5.6/prepare.yml new file mode 100644 index 000000000..5892f848c --- /dev/null +++ b/molecule/mysql.5.6/prepare.yml @@ -0,0 +1,12 @@ +--- + +- hosts: + - debian.stretch + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - mysql@mysql_5_6 diff --git a/molecule/mysql.5.7/converge.yml b/molecule/mysql.5.7/converge.yml new file mode 100644 index 000000000..704cf7bfe --- /dev/null +++ b/molecule/mysql.5.7/converge.yml @@ -0,0 +1,232 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.mysql + vars: + manala_mysql_users: + - name: foo + password: foo + host: localhost + priv: "*.*:ALL,GRANT" + - name: bar + state: ignore + # Flatten + - + - name: baz + password: baz + host: localhost + priv: "*.*:ALL,GRANT" + manala_mysql_databases: + - name: foo + - name: bar + state: ignore + # Flatten + - + - name: baz + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: + - debian.stretch + - debian.buster + vars: + tests_dir: /molecule/mysql/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.mysql + vars: + manala_mysql_config_file: "{{ tests_dir }}/dict" + manala_mysql_config_template: ~ + manala_mysql_config: + mysqld: + bind-address: 1.2.3.4 + pid-file: /var/run/mysqld/mysqld.pid + - name: Role - Content + import_role: + name: manala.roles.mysql + tasks_from: config + vars: + manala_mysql_config_file: "{{ tests_dir }}/content" + manala_mysql_config_template: ~ + manala_mysql_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.mysql + tasks_from: config + vars: + manala_mysql_config_file: "{{ tests_dir }}/template" + manala_mysql_config_template: fixtures/template.j2 + manala_mysql_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: + - debian.stretch + - debian.buster + vars: + tests_dir: /molecule/mysql/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.mysql + vars: + manala_mysql_configs_exclusive: false + manala_mysql_configs_dir: "{{ tests_dir }}/default" + manala_mysql_configs_defaults: {} + manala_mysql_configs: + # Dict + - file: dict + config: + mysqld: + user: mysql + query_cache_size: 0 + gtid_mode: true + enforce_gtid_consistency: false + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.mysql + tasks_from: configs + vars: + manala_mysql_configs_exclusive: false + manala_mysql_configs_dir: "{{ tests_dir }}/defaults" + manala_mysql_configs_defaults: + template: fixtures/template.j2 + manala_mysql_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.mysql + tasks_from: configs + vars: + manala_mysql_configs_exclusive: true + manala_mysql_configs_dir: "{{ tests_dir }}/exclusive" + manala_mysql_configs_defaults: {} + manala_mysql_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" + +############ +# Data Dir # +############ + +- name: Data Dir + tags: [data_dir] + hosts: + - debian.stretch + - debian.buster + vars: + tests_dir: /molecule/mysql/data_dir + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + name: manala.roles.mysql + vars: + manala_mysql_config: | + [mysqld] + pid-file = /var/run/mysqld/mysqld.pid + socket = /var/run/mysqld/mysqld.sock + log-error = /var/log/mysql/error.log + datadir = {{ tests_dir }}/data + manala_mysql_data_dir: "{{ tests_dir }}/data" + manala_mysql_data_dir_user: mysql + manala_mysql_data_dir_group: root + manala_mysql_data_dir_mode: "0700" + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/data_dir.yml.j2') }}" diff --git a/molecule/mysql.5.7/fixtures/template.j2 b/molecule/mysql.5.7/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/mysql.5.7/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/mysql.5.7/fixtures/template_file.j2 b/molecule/mysql.5.7/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/mysql.5.7/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/mysql.5.7/goss/config.yml.j2 b/molecule/mysql.5.7/goss/config.yml.j2 new file mode 100644 index 000000000..1b8446241 --- /dev/null +++ b/molecule/mysql.5.7/goss/config.yml.j2 @@ -0,0 +1,29 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[mysqld]" + - "bind-address = 1.2.3.4" + - "pid-file = /var/run/mysqld/mysqld.pid" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/mysql.5.7/goss/configs.yml.j2 b/molecule/mysql.5.7/goss/configs.yml.j2 new file mode 100644 index 000000000..d1fd2a908 --- /dev/null +++ b/molecule/mysql.5.7/goss/configs.yml.j2 @@ -0,0 +1,112 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[mysqld]" + - "user = mysql" + - "query_cache_size = 0" + - "gtid_mode = ON" + - "enforce_gtid_consistency = OFF" + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/mysql.5.7/goss/data_dir.yml.j2 b/molecule/mysql.5.7/goss/data_dir.yml.j2 new file mode 100644 index 000000000..7fadbbc74 --- /dev/null +++ b/molecule/mysql.5.7/goss/data_dir.yml.j2 @@ -0,0 +1,18 @@ +--- + +file: + {{ tests_dir }}/data: + exists: true + filetype: directory + owner: mysql + group: root + mode: "0700" + {{ tests_dir }}/data/ibdata1: + exists: true + filetype: file + +command: + mysql -BNe "SELECT @@GLOBAL.datadir": + exit-status: 0 + stdout: + - "{{ tests_dir }}/data" diff --git a/molecule/mysql.5.7/goss/default.yml.j2 b/molecule/mysql.5.7/goss/default.yml.j2 new file mode 100644 index 000000000..3d5bc9e84 --- /dev/null +++ b/molecule/mysql.5.7/goss/default.yml.j2 @@ -0,0 +1,38 @@ +--- + +package: + mysql-server: + installed: true + mysql-client: + installed: true + +command: + mysql --version: + exit-status: 0 + stdout: + - "/mysql(.)*Distrib 5.7/" + mysql -u root --execute "select user from mysql.user": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + mysqladmin --user=foo --password=foo ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysqladmin --user=baz --password=baz ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysql -u root --execute "show databases": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + +service: + mysql: + enabled: true + running: true diff --git a/molecule/mysql.5.7/molecule.yml b/molecule/mysql.5.7/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mysql.5.7/prepare.yml b/molecule/mysql.5.7/prepare.yml new file mode 100644 index 000000000..a5ae56c8d --- /dev/null +++ b/molecule/mysql.5.7/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - mysql@mysql_5_7 diff --git a/molecule/mysql.8.0/converge.yml b/molecule/mysql.8.0/converge.yml new file mode 100644 index 000000000..497932db4 --- /dev/null +++ b/molecule/mysql.8.0/converge.yml @@ -0,0 +1,232 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.mysql + vars: + manala_mysql_configs: + # Use native authentication plugin + - file: auth.cnf + config: + mysqld: + default-authentication-plugin: mysql_native_password + manala_mysql_users: + - name: foo + password: foo + host: localhost + priv: "*.*:ALL,GRANT" + - name: bar + state: ignore + # Flatten + - + - name: baz + password: baz + host: localhost + priv: "*.*:ALL,GRANT" + manala_mysql_databases: + - name: foo + - name: bar + state: ignore + # Flatten + - + - name: baz + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/mysql/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.mysql + vars: + manala_mysql_config_file: "{{ tests_dir }}/dict" + manala_mysql_config_template: ~ + manala_mysql_config: + mysqld: + bind-address: 1.2.3.4 + pid-file: /var/run/mysqld/mysqld.pid + - name: Role - Content + import_role: + name: manala.roles.mysql + tasks_from: config + vars: + manala_mysql_config_file: "{{ tests_dir }}/content" + manala_mysql_config_template: ~ + manala_mysql_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.mysql + tasks_from: config + vars: + manala_mysql_config_file: "{{ tests_dir }}/template" + manala_mysql_config_template: fixtures/template.j2 + manala_mysql_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/mysql/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.mysql + vars: + manala_mysql_configs_exclusive: false + manala_mysql_configs_dir: "{{ tests_dir }}/default" + manala_mysql_configs_defaults: {} + manala_mysql_configs: + # Dict + - file: dict + config: + mysqld: + user: mysql + query_cache_size: 0 + gtid_mode: true + enforce_gtid_consistency: false + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.mysql + tasks_from: configs + vars: + manala_mysql_configs_exclusive: false + manala_mysql_configs_dir: "{{ tests_dir }}/defaults" + manala_mysql_configs_defaults: + template: fixtures/template.j2 + manala_mysql_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.mysql + tasks_from: configs + vars: + manala_mysql_configs_exclusive: true + manala_mysql_configs_dir: "{{ tests_dir }}/exclusive" + manala_mysql_configs_defaults: {} + manala_mysql_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" + +############ +# Data Dir # +############ + +- name: Data Dir + tags: [data_dir] + hosts: debian + vars: + tests_dir: /molecule/mysql/data_dir + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + name: manala.roles.mysql + vars: + manala_mysql_config: | + [mysqld] + pid-file = /var/run/mysqld/mysqld.pid + socket = /var/run/mysqld/mysqld.sock + log-error = /var/log/mysql/error.log + datadir = {{ tests_dir }}/data + # Use native authentication plugin + default-authentication-plugin = mysql_native_password + manala_mysql_data_dir: "{{ tests_dir }}/data" + manala_mysql_data_dir_user: mysql + manala_mysql_data_dir_group: root + manala_mysql_data_dir_mode: "0700" + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/data_dir.yml.j2') }}" diff --git a/molecule/mysql.8.0/fixtures/template.j2 b/molecule/mysql.8.0/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/mysql.8.0/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/mysql.8.0/fixtures/template_file.j2 b/molecule/mysql.8.0/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/mysql.8.0/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/mysql.8.0/goss/config.yml.j2 b/molecule/mysql.8.0/goss/config.yml.j2 new file mode 100644 index 000000000..1b8446241 --- /dev/null +++ b/molecule/mysql.8.0/goss/config.yml.j2 @@ -0,0 +1,29 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[mysqld]" + - "bind-address = 1.2.3.4" + - "pid-file = /var/run/mysqld/mysqld.pid" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/mysql.8.0/goss/configs.yml.j2 b/molecule/mysql.8.0/goss/configs.yml.j2 new file mode 100644 index 000000000..d1fd2a908 --- /dev/null +++ b/molecule/mysql.8.0/goss/configs.yml.j2 @@ -0,0 +1,112 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[mysqld]" + - "user = mysql" + - "query_cache_size = 0" + - "gtid_mode = ON" + - "enforce_gtid_consistency = OFF" + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/mysql.8.0/goss/data_dir.yml.j2 b/molecule/mysql.8.0/goss/data_dir.yml.j2 new file mode 100644 index 000000000..7fadbbc74 --- /dev/null +++ b/molecule/mysql.8.0/goss/data_dir.yml.j2 @@ -0,0 +1,18 @@ +--- + +file: + {{ tests_dir }}/data: + exists: true + filetype: directory + owner: mysql + group: root + mode: "0700" + {{ tests_dir }}/data/ibdata1: + exists: true + filetype: file + +command: + mysql -BNe "SELECT @@GLOBAL.datadir": + exit-status: 0 + stdout: + - "{{ tests_dir }}/data" diff --git a/molecule/mysql.8.0/goss/default.yml.j2 b/molecule/mysql.8.0/goss/default.yml.j2 new file mode 100644 index 000000000..5058f9120 --- /dev/null +++ b/molecule/mysql.8.0/goss/default.yml.j2 @@ -0,0 +1,38 @@ +--- + +package: + mysql-server: + installed: true + mysql-client: + installed: true + +command: + mysql --version: + exit-status: 0 + stdout: + - "/mysql(.)*Ver 8.0/" + mysql -u root --execute "select user from mysql.user": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + mysqladmin --user=foo --password=foo ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysqladmin --user=baz --password=baz ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysql -u root --execute "show databases": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + +service: + mysql: + enabled: true + running: true diff --git a/molecule/mysql.8.0/molecule.yml b/molecule/mysql.8.0/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mysql.8.0/prepare.yml b/molecule/mysql.8.0/prepare.yml new file mode 100644 index 000000000..9d11505db --- /dev/null +++ b/molecule/mysql.8.0/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - mysql@mysql_8_0 diff --git a/molecule/mysql.galera.3.mysql_wsrep.5.6/converge.yml b/molecule/mysql.galera.3.mysql_wsrep.5.6/converge.yml new file mode 100644 index 000000000..a5349f519 --- /dev/null +++ b/molecule/mysql.galera.3.mysql_wsrep.5.6/converge.yml @@ -0,0 +1,46 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + tasks: + - block: + - name: Role + import_role: + name: manala.roles.mysql + vars: + manala_mysql_install_packages: + - galera-3 + - galera-arbitrator-3 + - mysql-wsrep-server-5.6 + - mysql-wsrep-client-5.6 + manala_mysql_users: + - name: foo + password: foo + host: localhost + priv: "*.*:ALL,GRANT" + - name: bar + state: ignore + # Flatten + - + - name: baz + password: baz + host: localhost + priv: "*.*:ALL,GRANT" + manala_mysql_databases: + - name: foo + - name: bar + state: ignore + # Flatten + - + - name: baz + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/mysql.galera.3.mysql_wsrep.5.6/goss/default.yml.j2 b/molecule/mysql.galera.3.mysql_wsrep.5.6/goss/default.yml.j2 new file mode 100644 index 000000000..016dda929 --- /dev/null +++ b/molecule/mysql.galera.3.mysql_wsrep.5.6/goss/default.yml.j2 @@ -0,0 +1,42 @@ +--- + +package: + galera-3: + installed: true + galera-arbitrator-3: + installed: true + mysql-wsrep-server-5.6: + installed: true + mysql-wsrep-client-5.6: + installed: true + +command: + mysql --version: + exit-status: 0 + stdout: + - "/mysql(.)*Distrib 5.6/" + mysql -u root --execute "select user from mysql.user": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + mysqladmin --user=foo --password=foo ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysqladmin --user=baz --password=baz ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysql -u root --execute "show databases": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + +service: + mysql: + enabled: true + running: true diff --git a/molecule/mysql.galera.3.mysql_wsrep.5.6/molecule.yml b/molecule/mysql.galera.3.mysql_wsrep.5.6/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mysql.galera.3.mysql_wsrep.5.6/prepare.yml b/molecule/mysql.galera.3.mysql_wsrep.5.6/prepare.yml new file mode 100644 index 000000000..aecdc5ae7 --- /dev/null +++ b/molecule/mysql.galera.3.mysql_wsrep.5.6/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: + - debian.stretch + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - galera@galera_3 + - mysql@mysql_wsrep_5_6 diff --git a/molecule/mysql.mariadb.10.3/converge.yml b/molecule/mysql.mariadb.10.3/converge.yml new file mode 100644 index 000000000..230b30512 --- /dev/null +++ b/molecule/mysql.mariadb.10.3/converge.yml @@ -0,0 +1,45 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.mysql + vars: + manala_mysql_install_packages: + - mariadb-server + - mariadb-client + manala_mysql_users: + - name: foo + password: foo + host: localhost + priv: "*.*:ALL,GRANT" + - name: bar + state: ignore + # Flatten + - + - name: baz + password: baz + host: localhost + priv: "*.*:ALL,GRANT" + manala_mysql_databases: + - name: foo + - name: bar + state: ignore + # Flatten + - + - name: baz + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/mysql.mariadb.10.3/goss/default.yml.j2 b/molecule/mysql.mariadb.10.3/goss/default.yml.j2 new file mode 100644 index 000000000..e95a39fc1 --- /dev/null +++ b/molecule/mysql.mariadb.10.3/goss/default.yml.j2 @@ -0,0 +1,41 @@ +--- + +package: + mariadb-server: + installed: true + mariadb-client: + installed: true + +command: + mysql --version: + exit-status: 0 + stdout: + - "/mysql(.)*Distrib 10.3.(.){2}-MariaDB/" + mysql -u root --execute "select user from mysql.user": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + mysqladmin --user=foo --password=foo ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysqladmin --user=baz --password=baz ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysql -u root --execute "show databases": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + +service: + mysql: # Alias to mariadb + enabled: true + running: true + mariadb: + enabled: true + running: true diff --git a/molecule/mysql.mariadb.10.3/molecule.yml b/molecule/mysql.mariadb.10.3/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mysql.mariadb.10.3/prepare.yml b/molecule/mysql.mariadb.10.3/prepare.yml new file mode 100644 index 000000000..df4f0d1b4 --- /dev/null +++ b/molecule/mysql.mariadb.10.3/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - mariadb@mariadb_10_3 diff --git a/molecule/mysql.mariadb.10.4/converge.yml b/molecule/mysql.mariadb.10.4/converge.yml new file mode 100644 index 000000000..230b30512 --- /dev/null +++ b/molecule/mysql.mariadb.10.4/converge.yml @@ -0,0 +1,45 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.mysql + vars: + manala_mysql_install_packages: + - mariadb-server + - mariadb-client + manala_mysql_users: + - name: foo + password: foo + host: localhost + priv: "*.*:ALL,GRANT" + - name: bar + state: ignore + # Flatten + - + - name: baz + password: baz + host: localhost + priv: "*.*:ALL,GRANT" + manala_mysql_databases: + - name: foo + - name: bar + state: ignore + # Flatten + - + - name: baz + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/mysql.mariadb.10.4/goss/default.yml.j2 b/molecule/mysql.mariadb.10.4/goss/default.yml.j2 new file mode 100644 index 000000000..1b0a5abae --- /dev/null +++ b/molecule/mysql.mariadb.10.4/goss/default.yml.j2 @@ -0,0 +1,41 @@ +--- + +package: + mariadb-server: + installed: true + mariadb-client: + installed: true + +command: + mysql --version: + exit-status: 0 + stdout: + - "/mysql(.)*Distrib 10.4.(.){2}-MariaDB/" + mysql -u root --execute "select user from mysql.user": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + mysqladmin --user=foo --password=foo ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysqladmin --user=baz --password=baz ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysql -u root --execute "show databases": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + +service: + mysql: # Alias to mariadb + enabled: true + running: true + mariadb: + enabled: true + running: true diff --git a/molecule/mysql.mariadb.10.4/molecule.yml b/molecule/mysql.mariadb.10.4/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mysql.mariadb.10.4/prepare.yml b/molecule/mysql.mariadb.10.4/prepare.yml new file mode 100644 index 000000000..2efd4c01a --- /dev/null +++ b/molecule/mysql.mariadb.10.4/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - mariadb@mariadb_10_4 diff --git a/molecule/mysql.mariadb.10.5/converge.yml b/molecule/mysql.mariadb.10.5/converge.yml new file mode 100644 index 000000000..58bdc1d18 --- /dev/null +++ b/molecule/mysql.mariadb.10.5/converge.yml @@ -0,0 +1,43 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.mysql + vars: + manala_mysql_install_packages: + - mariadb-server + - mariadb-client + manala_mysql_users: + - name: foo + password: foo + host: localhost + priv: "*.*:ALL,GRANT" + - name: bar + state: ignore + # Flatten + - + - name: baz + password: baz + host: localhost + priv: "*.*:ALL,GRANT" + manala_mysql_databases: + - name: foo + - name: bar + state: ignore + # Flatten + - + - name: baz + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/mysql.mariadb.10.5/goss/default.yml.j2 b/molecule/mysql.mariadb.10.5/goss/default.yml.j2 new file mode 100644 index 000000000..226fa7999 --- /dev/null +++ b/molecule/mysql.mariadb.10.5/goss/default.yml.j2 @@ -0,0 +1,41 @@ +--- + +package: + mariadb-server: + installed: true + mariadb-client: + installed: true + +command: + mysql --version: + exit-status: 0 + stdout: + - "/mysql(.)*Distrib 10.5.(.){1,2}-MariaDB/" + mysql -u root --execute "select user from mysql.user": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + mysqladmin --user=foo --password=foo ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysqladmin --user=baz --password=baz ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysql -u root --execute "show databases": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + +service: + mysql: # Alias to mariadb + enabled: true + running: true + mariadb: + enabled: true + running: true diff --git a/molecule/mysql.mariadb.10.5/molecule.yml b/molecule/mysql.mariadb.10.5/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mysql.mariadb.10.5/prepare.yml b/molecule/mysql.mariadb.10.5/prepare.yml new file mode 100644 index 000000000..1aeba6c79 --- /dev/null +++ b/molecule/mysql.mariadb.10.5/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - mariadb@mariadb_10_5 diff --git a/molecule/mysql.mariadb.10.6/converge.yml b/molecule/mysql.mariadb.10.6/converge.yml new file mode 100644 index 000000000..cdb9cb07b --- /dev/null +++ b/molecule/mysql.mariadb.10.6/converge.yml @@ -0,0 +1,238 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.mysql + vars: + manala_mysql_install_packages: + - mariadb-server + - mariadb-client + manala_mysql_users: + - name: foo + password: foo + host: localhost + priv: "*.*:ALL,GRANT" + - name: bar + state: ignore + # Flatten + - + - name: baz + password: baz + host: localhost + priv: "*.*:ALL,GRANT" + manala_mysql_databases: + - name: foo + - name: bar + state: ignore + # Flatten + - + - name: baz + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/mysql/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.mysql + vars: + manala_mysql_install_packages: + - mariadb-server + - mariadb-client + manala_mysql_config_file: "{{ tests_dir }}/dict" + manala_mysql_config_template: ~ + manala_mysql_config: + mysqld: + bind-address: 1.2.3.4 + pid-file: /var/run/mysqld/mysqld.pid + - name: Role - Content + import_role: + name: manala.roles.mysql + tasks_from: config + vars: + manala_mysql_config_file: "{{ tests_dir }}/content" + manala_mysql_config_template: ~ + manala_mysql_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.mysql + tasks_from: config + vars: + manala_mysql_config_file: "{{ tests_dir }}/template" + manala_mysql_config_template: fixtures/template.j2 + manala_mysql_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/mysql/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.mysql + vars: + manala_mysql_install_packages: + - mariadb-server + - mariadb-client + manala_mysql_configs_exclusive: false + manala_mysql_configs_dir: "{{ tests_dir }}/default" + manala_mysql_configs_defaults: {} + manala_mysql_configs: + # Dict + - file: dict + config: + mysqld: + user: mysql + query_cache_size: 0 + gtid_mode: true + enforce_gtid_consistency: false + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.mysql + tasks_from: configs + vars: + manala_mysql_configs_exclusive: false + manala_mysql_configs_dir: "{{ tests_dir }}/defaults" + manala_mysql_configs_defaults: + template: fixtures/template.j2 + manala_mysql_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.mysql + tasks_from: configs + vars: + manala_mysql_configs_exclusive: true + manala_mysql_configs_dir: "{{ tests_dir }}/exclusive" + manala_mysql_configs_defaults: {} + manala_mysql_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" + +############ +# Data Dir # +############ + +- name: Data Dir + tags: [data_dir] + hosts: debian + vars: + tests_dir: /molecule/mysql/data_dir + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + name: manala.roles.mysql + vars: + manala_mysql_install_packages: + - mariadb-server + - mariadb-client + manala_mysql_configs_dir: /etc/mysql/mariadb.conf.d + manala_mysql_configs: + - file: 90-datadir.cnf + config: | + [mysqld] + datadir = {{ tests_dir }}/data + manala_mysql_data_dir: "{{ tests_dir }}/data" + manala_mysql_data_dir_user: mysql + manala_mysql_data_dir_group: mysql + manala_mysql_data_dir_mode: "0750" + manala_mysql_data_dir_initialize: true + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/data_dir.yml.j2') }}" diff --git a/molecule/mysql.mariadb.10.6/fixtures/template.j2 b/molecule/mysql.mariadb.10.6/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/mysql.mariadb.10.6/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/mysql.mariadb.10.6/fixtures/template_file.j2 b/molecule/mysql.mariadb.10.6/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/mysql.mariadb.10.6/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/mysql.mariadb.10.6/goss/config.yml.j2 b/molecule/mysql.mariadb.10.6/goss/config.yml.j2 new file mode 100644 index 000000000..1b8446241 --- /dev/null +++ b/molecule/mysql.mariadb.10.6/goss/config.yml.j2 @@ -0,0 +1,29 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[mysqld]" + - "bind-address = 1.2.3.4" + - "pid-file = /var/run/mysqld/mysqld.pid" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/mysql.mariadb.10.6/goss/configs.yml.j2 b/molecule/mysql.mariadb.10.6/goss/configs.yml.j2 new file mode 100644 index 000000000..d1fd2a908 --- /dev/null +++ b/molecule/mysql.mariadb.10.6/goss/configs.yml.j2 @@ -0,0 +1,112 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[mysqld]" + - "user = mysql" + - "query_cache_size = 0" + - "gtid_mode = ON" + - "enforce_gtid_consistency = OFF" + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/mysql.mariadb.10.6/goss/data_dir.yml.j2 b/molecule/mysql.mariadb.10.6/goss/data_dir.yml.j2 new file mode 100644 index 000000000..6c1f416de --- /dev/null +++ b/molecule/mysql.mariadb.10.6/goss/data_dir.yml.j2 @@ -0,0 +1,18 @@ +--- + +file: + {{ tests_dir }}/data: + exists: true + filetype: directory + owner: mysql + group: mysql + mode: "0750" + {{ tests_dir }}/data/ibdata1: + exists: true + filetype: file + +command: + mysql -BNe "SELECT @@GLOBAL.datadir": + exit-status: 0 + stdout: + - "{{ tests_dir }}/data" diff --git a/molecule/mysql.mariadb.10.6/goss/default.yml.j2 b/molecule/mysql.mariadb.10.6/goss/default.yml.j2 new file mode 100644 index 000000000..cc3f5b5e1 --- /dev/null +++ b/molecule/mysql.mariadb.10.6/goss/default.yml.j2 @@ -0,0 +1,41 @@ +--- + +package: + mariadb-server: + installed: true + mariadb-client: + installed: true + +command: + mysql --version: + exit-status: 0 + stdout: + - "/mysql(.)*Distrib 10.6.(.){1,2}-MariaDB/" + mysql -u root --execute "select user from mysql.user": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + mysqladmin --user=foo --password=foo ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysqladmin --user=baz --password=baz ping: + exit-status: 0 + stdout: + - "mysqld is alive" + mysql -u root --execute "show databases": + exit-status: 0 + stdout: + - foo + - "!bar" + - baz + +service: + mysql: # Alias to mariadb + enabled: true + running: true + mariadb: + enabled: true + running: true diff --git a/molecule/mysql.mariadb.10.6/molecule.yml b/molecule/mysql.mariadb.10.6/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/mysql.mariadb.10.6/prepare.yml b/molecule/mysql.mariadb.10.6/prepare.yml new file mode 100644 index 000000000..166794aba --- /dev/null +++ b/molecule/mysql.mariadb.10.6/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - mariadb@mariadb_10_6 diff --git a/molecule/network/converge.yml b/molecule/network/converge.yml new file mode 100644 index 000000000..de45899bc --- /dev/null +++ b/molecule/network/converge.yml @@ -0,0 +1,262 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.network + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +######### +# Hosts # +######### + +- name: Hosts + tags: [hosts] + hosts: debian + vars: + tests_dir: /molecule/network/hosts + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - name: File # noqa risky-file-permissions + copy: + dest: "{{ tests_dir }}/dict" + content: | + 1.1.1.111 bar.com + 1.1.1.222 bar.com + - block: + - name: Role - Dict + import_role: + name: manala.roles.network + vars: + manala_network_hosts_file: "{{ tests_dir }}/dict" + manala_network_hosts: + 1.1.1.111: foo.com + 1.1.1.2: baz.com + 1.1.1.333: qux.com + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/hosts.yml.j2') }}" + +################### +# Resolver Config # +################### + +- name: Resolver Config + tags: [resolver_config] + hosts: debian + vars: + tests_dir: /molecule/network/resolver_config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Content + import_role: + name: manala.roles.network + tasks_from: resolver_config + vars: + manala_network_resolver_config_file: "{{ tests_dir }}/content" + manala_network_resolver_config_template: ~ + manala_network_resolver_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.network + tasks_from: resolver_config + vars: + manala_network_resolver_config_file: "{{ tests_dir }}/template" + manala_network_resolver_config_template: fixtures/template.j2 + manala_network_resolver_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/resolver_config.yml.j2') }}" + +##################### +# Interfaces Config # +##################### + +- name: Interfaces Config + tags: [interfaces_config] + hosts: debian + vars: + tests_dir: /molecule/network/interfaces_config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Content + import_role: + name: manala.roles.network + tasks_from: interfaces_config + vars: + manala_network_interfaces_config_file: "{{ tests_dir }}/content" + manala_network_interfaces_config_template: ~ + manala_network_interfaces_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.network + tasks_from: interfaces_config + vars: + manala_network_interfaces_config_file: "{{ tests_dir }}/template" + manala_network_interfaces_config_template: fixtures/template.j2 + manala_network_interfaces_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/interfaces_config.yml.j2') }}" + +###################### +# Interfaces Configs # +###################### + +- name: Interfaces Configs + tags: [interfaces_configs] + hosts: debian + vars: + tests_dir: /molecule/network/interfaces_configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.network + tasks_from: interfaces_configs + vars: + manala_network_interfaces_configs_exclusive: false + manala_network_interfaces_configs_dir: "{{ tests_dir }}/default" + manala_network_interfaces_configs_defaults: {} + manala_network_interfaces_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.network + tasks_from: interfaces_configs + vars: + manala_network_interfaces_configs_exclusive: false + manala_network_interfaces_configs_dir: "{{ tests_dir }}/defaults" + manala_network_interfaces_configs_defaults: + template: fixtures/template.j2 + manala_network_interfaces_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.network + tasks_from: interfaces_configs + vars: + manala_network_interfaces_configs_exclusive: true + manala_network_interfaces_configs_dir: "{{ tests_dir }}/exclusive" + manala_network_interfaces_configs_defaults: {} + manala_network_interfaces_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/interfaces_configs.yml.j2') }}" + +################## +# Routing Tables # +################## + +- name: Routing Tables + tags: [routing_tables] + hosts: debian + vars: + tests_dir: /molecule/network/routing_tables + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - name: File # noqa risky-file-permissions no-tabs + copy: + dest: "{{ tests_dir }}/dict" + content: | + 255 local + 254 main + 253 foo + - block: + - name: Role - Dict + import_role: + name: manala.roles.network + vars: + manala_network_routing_tables_file: "{{ tests_dir }}/dict" + manala_network_routing_tables: + 253: default + 25: foo + 123: bar + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/routing_tables.yml.j2') }}" diff --git a/molecule/network/fixtures/template.j2 b/molecule/network/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/network/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/network/fixtures/template_file.j2 b/molecule/network/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/network/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/roles/network/tests/0100_install.goss.yml b/molecule/network/goss/default.yml.j2 similarity index 100% rename from roles/network/tests/0100_install.goss.yml rename to molecule/network/goss/default.yml.j2 diff --git a/molecule/network/goss/hosts.yml.j2 b/molecule/network/goss/hosts.yml.j2 new file mode 100644 index 000000000..21f741833 --- /dev/null +++ b/molecule/network/goss/hosts.yml.j2 @@ -0,0 +1,14 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "1.1.1.111 foo.com" + - "1.1.1.222 bar.com" + - "1.1.1.2 baz.com" + - "1.1.1.333 qux.com" diff --git a/molecule/network/goss/interfaces_config.yml.j2 b/molecule/network/goss/interfaces_config.yml.j2 new file mode 100644 index 000000000..30ac39316 --- /dev/null +++ b/molecule/network/goss/interfaces_config.yml.j2 @@ -0,0 +1,19 @@ +--- + +file: + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/network/goss/interfaces_configs.yml.j2 b/molecule/network/goss/interfaces_configs.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/network/goss/interfaces_configs.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/network/goss/resolver_config.yml.j2 b/molecule/network/goss/resolver_config.yml.j2 new file mode 100644 index 000000000..30ac39316 --- /dev/null +++ b/molecule/network/goss/resolver_config.yml.j2 @@ -0,0 +1,19 @@ +--- + +file: + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/network/goss/routing_tables.yml.j2 b/molecule/network/goss/routing_tables.yml.j2 new file mode 100644 index 000000000..984c8bc52 --- /dev/null +++ b/molecule/network/goss/routing_tables.yml.j2 @@ -0,0 +1,15 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "255 local" + - "254 main" + - "253 default" + - "25 foo" + - "123 bar" diff --git a/molecule/network/molecule.yml b/molecule/network/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/nginx/converge.yml b/molecule/nginx/converge.yml new file mode 100644 index 000000000..721e07baa --- /dev/null +++ b/molecule/nginx/converge.yml @@ -0,0 +1,175 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.nginx + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/nginx/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.nginx + vars: + manala_nginx_config_file: "{{ tests_dir }}/dict" + manala_nginx_config_template: ~ + manala_nginx_config: + _true: true + _false: false + _array: + - foo + - bar + _string: string + _integer: 123 + _float: 4.56 + - name: Role - Content + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.nginx + vars: + manala_nginx_config_file: "{{ tests_dir }}/content" + manala_nginx_config_template: ~ + manala_nginx_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.nginx + tasks_from: config + vars: + manala_nginx_config_file: "{{ tests_dir }}/template" + manala_nginx_config_template: fixtures/template.j2 + manala_nginx_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/nginx/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.nginx + tasks_from: configs + vars: + manala_nginx_configs_exclusive: false + manala_nginx_configs_dir: "{{ tests_dir }}/default" + manala_nginx_configs_defaults: {} + manala_nginx_configs: + # Dict + - file: dict + config: + _true: true + _false: false + _array: + - foo + - bar + _string: string + _integer: 123 + _float: 4.56 + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.nginx + tasks_from: configs + vars: + manala_nginx_configs_exclusive: false + manala_nginx_configs_dir: "{{ tests_dir }}/defaults" + manala_nginx_configs_defaults: + template: fixtures/template.j2 + manala_nginx_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.nginx + tasks_from: configs + vars: + manala_nginx_configs_exclusive: true + manala_nginx_configs_dir: "{{ tests_dir }}/exclusive" + manala_nginx_configs_defaults: {} + manala_nginx_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" diff --git a/molecule/nginx/fixtures/template.j2 b/molecule/nginx/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/nginx/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/nginx/fixtures/template_file.j2 b/molecule/nginx/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/nginx/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/nginx/goss/config.yml.j2 b/molecule/nginx/goss/config.yml.j2 new file mode 100644 index 000000000..1a9847208 --- /dev/null +++ b/molecule/nginx/goss/config.yml.j2 @@ -0,0 +1,33 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - _true on; + - _false off; + - _array foo; + - _array bar; + - _string string; + - _integer 123; + - _float 4.56; + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/nginx/goss/configs.yml.j2 b/molecule/nginx/goss/configs.yml.j2 new file mode 100644 index 000000000..b1c846f53 --- /dev/null +++ b/molecule/nginx/goss/configs.yml.j2 @@ -0,0 +1,114 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - _true on; + - _false off; + - _array foo; + - _array bar; + - _string string; + - _integer 123; + - _float 4.56; + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/roles/nginx/tests/0000_default.goss.yml b/molecule/nginx/goss/default.yml.j2 similarity index 100% rename from roles/nginx/tests/0000_default.goss.yml rename to molecule/nginx/goss/default.yml.j2 diff --git a/molecule/nginx/molecule.yml b/molecule/nginx/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/nginx/prepare.yml b/molecule/nginx/prepare.yml new file mode 100644 index 000000000..0d2538479 --- /dev/null +++ b/molecule/nginx/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - nginx@nginx diff --git a/molecule/ngrok/converge.yml b/molecule/ngrok/converge.yml new file mode 100644 index 000000000..22bf8aad1 --- /dev/null +++ b/molecule/ngrok/converge.yml @@ -0,0 +1,142 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.ngrok + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Version # +########### + +- name: Version + tags: [version] + hosts: debian + vars: + tests_dir: /molecule/ngrok/version + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Fixed + import_role: + name: manala.roles.ngrok + tasks_from: install + vars: + manala_ngrok_bin: "{{ tests_dir }}/fixed" + manala_ngrok_version: 2.2.2 + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/version.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/ngrok/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.ngrok + tasks_from: configs + vars: + manala_ngrok_configs_exclusive: false + manala_ngrok_configs_dir: "{{ tests_dir }}/default" + manala_ngrok_configs_defaults: {} + manala_ngrok_configs: + # Dict + - file: dict + config: + web_addr: 1.2.3.4:1234 + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.ngrok + tasks_from: configs + vars: + manala_ngrok_configs_exclusive: false + manala_ngrok_configs_dir: "{{ tests_dir }}/defaults" + manala_ngrok_configs_defaults: + template: fixtures/template.j2 + manala_ngrok_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.ngrok + tasks_from: configs + vars: + manala_ngrok_configs_exclusive: true + manala_ngrok_configs_dir: "{{ tests_dir }}/exclusive" + manala_ngrok_configs_defaults: {} + manala_ngrok_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" diff --git a/molecule/ngrok/fixtures/template.j2 b/molecule/ngrok/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/ngrok/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/ngrok/fixtures/template_file.j2 b/molecule/ngrok/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/ngrok/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/ngrok/goss/configs.yml.j2 b/molecule/ngrok/goss/configs.yml.j2 new file mode 100644 index 000000000..3b01474d3 --- /dev/null +++ b/molecule/ngrok/goss/configs.yml.j2 @@ -0,0 +1,108 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - 'web_addr: 1.2.3.4:1234' + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/ngrok/goss/default.yml.j2 b/molecule/ngrok/goss/default.yml.j2 new file mode 100644 index 000000000..bb47f5cef --- /dev/null +++ b/molecule/ngrok/goss/default.yml.j2 @@ -0,0 +1,15 @@ +--- + +file: + {{ manala_ngrok_bin }}: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + +command: + {{ manala_ngrok_bin }} --version: + exit-status: 0 + stdout: + - ngrok version diff --git a/molecule/ngrok/goss/version.yml.j2 b/molecule/ngrok/goss/version.yml.j2 new file mode 100644 index 000000000..13733e129 --- /dev/null +++ b/molecule/ngrok/goss/version.yml.j2 @@ -0,0 +1,17 @@ +--- + +file: + # Fixed + {{ tests_dir }}/fixed: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + +command: + # Fixed + {{ tests_dir }}/fixed --version: + exit-status: 0 + stdout: + - ngrok version 2.2.2 diff --git a/molecule/ngrok/molecule.yml b/molecule/ngrok/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/nodejs.10/converge.yml b/molecule/nodejs.10/converge.yml new file mode 100644 index 000000000..cda7d6bd2 --- /dev/null +++ b/molecule/nodejs.10/converge.yml @@ -0,0 +1,19 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.nodejs + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/nodejs/tests/0108_install.10.goss.yml b/molecule/nodejs.10/goss/default.yml.j2 similarity index 100% rename from roles/nodejs/tests/0108_install.10.goss.yml rename to molecule/nodejs.10/goss/default.yml.j2 diff --git a/molecule/nodejs.10/molecule.yml b/molecule/nodejs.10/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/nodejs.10/prepare.yml b/molecule/nodejs.10/prepare.yml new file mode 100644 index 000000000..d311ab7a5 --- /dev/null +++ b/molecule/nodejs.10/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - nodejs@nodesource_10 diff --git a/molecule/nodejs.12/converge.yml b/molecule/nodejs.12/converge.yml new file mode 100644 index 000000000..cda7d6bd2 --- /dev/null +++ b/molecule/nodejs.12/converge.yml @@ -0,0 +1,19 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.nodejs + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/nodejs/tests/0109_install.12.goss.yml b/molecule/nodejs.12/goss/default.yml.j2 similarity index 100% rename from roles/nodejs/tests/0109_install.12.goss.yml rename to molecule/nodejs.12/goss/default.yml.j2 diff --git a/molecule/nodejs.12/molecule.yml b/molecule/nodejs.12/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/nodejs.12/prepare.yml b/molecule/nodejs.12/prepare.yml new file mode 100644 index 000000000..4b6da8acf --- /dev/null +++ b/molecule/nodejs.12/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - nodejs@nodesource_12 diff --git a/molecule/nodejs.14/converge.yml b/molecule/nodejs.14/converge.yml new file mode 100644 index 000000000..cda7d6bd2 --- /dev/null +++ b/molecule/nodejs.14/converge.yml @@ -0,0 +1,19 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.nodejs + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/nodejs/tests/0110_install.14.goss.yml b/molecule/nodejs.14/goss/default.yml.j2 similarity index 100% rename from roles/nodejs/tests/0110_install.14.goss.yml rename to molecule/nodejs.14/goss/default.yml.j2 diff --git a/molecule/nodejs.14/molecule.yml b/molecule/nodejs.14/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/nodejs.14/prepare.yml b/molecule/nodejs.14/prepare.yml new file mode 100644 index 000000000..13ee94141 --- /dev/null +++ b/molecule/nodejs.14/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - nodejs@nodesource_14 diff --git a/molecule/nodejs.16/converge.yml b/molecule/nodejs.16/converge.yml new file mode 100644 index 000000000..cda7d6bd2 --- /dev/null +++ b/molecule/nodejs.16/converge.yml @@ -0,0 +1,19 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.nodejs + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/nodejs.16/goss/default.yml.j2 b/molecule/nodejs.16/goss/default.yml.j2 new file mode 100644 index 000000000..34d2f351b --- /dev/null +++ b/molecule/nodejs.16/goss/default.yml.j2 @@ -0,0 +1,15 @@ +--- + +package: + nodejs: + installed: true + +command: + node --version: + exit-status: 0 + stdout: + - "/^v16.\\d+\\.\\d+$/" + npm --version: + exit-status: 0 + stdout: + - "/^8.\\d+\\.\\d+$/" diff --git a/molecule/nodejs.16/molecule.yml b/molecule/nodejs.16/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/nodejs.16/prepare.yml b/molecule/nodejs.16/prepare.yml new file mode 100644 index 000000000..c13d8f719 --- /dev/null +++ b/molecule/nodejs.16/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - nodejs@nodesource_16 diff --git a/molecule/nodejs.4/converge.yml b/molecule/nodejs.4/converge.yml new file mode 100644 index 000000000..2fb565436 --- /dev/null +++ b/molecule/nodejs.4/converge.yml @@ -0,0 +1,21 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.nodejs + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/nodejs/tests/0102_install.4.goss.yml b/molecule/nodejs.4/goss/default.yml.j2 similarity index 100% rename from roles/nodejs/tests/0102_install.4.goss.yml rename to molecule/nodejs.4/goss/default.yml.j2 diff --git a/molecule/nodejs.4/molecule.yml b/molecule/nodejs.4/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/nodejs.4/prepare.yml b/molecule/nodejs.4/prepare.yml new file mode 100644 index 000000000..ab21c52bc --- /dev/null +++ b/molecule/nodejs.4/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - nodejs@nodesource_4 diff --git a/molecule/nodejs.6/converge.yml b/molecule/nodejs.6/converge.yml new file mode 100644 index 000000000..2fb565436 --- /dev/null +++ b/molecule/nodejs.6/converge.yml @@ -0,0 +1,21 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.nodejs + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/nodejs/tests/0104_install.6.goss.yml b/molecule/nodejs.6/goss/default.yml.j2 similarity index 100% rename from roles/nodejs/tests/0104_install.6.goss.yml rename to molecule/nodejs.6/goss/default.yml.j2 diff --git a/molecule/nodejs.6/molecule.yml b/molecule/nodejs.6/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/nodejs.6/prepare.yml b/molecule/nodejs.6/prepare.yml new file mode 100644 index 000000000..51eae1615 --- /dev/null +++ b/molecule/nodejs.6/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - nodejs@nodesource_6 diff --git a/molecule/nodejs.7/converge.yml b/molecule/nodejs.7/converge.yml new file mode 100644 index 000000000..2fb565436 --- /dev/null +++ b/molecule/nodejs.7/converge.yml @@ -0,0 +1,21 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.nodejs + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/nodejs/tests/0105_install.7.goss.yml b/molecule/nodejs.7/goss/default.yml.j2 similarity index 100% rename from roles/nodejs/tests/0105_install.7.goss.yml rename to molecule/nodejs.7/goss/default.yml.j2 diff --git a/molecule/nodejs.7/molecule.yml b/molecule/nodejs.7/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/nodejs.7/prepare.yml b/molecule/nodejs.7/prepare.yml new file mode 100644 index 000000000..bd4ac2476 --- /dev/null +++ b/molecule/nodejs.7/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - nodejs@nodesource_7 diff --git a/molecule/nodejs.8/converge.yml b/molecule/nodejs.8/converge.yml new file mode 100644 index 000000000..2fb565436 --- /dev/null +++ b/molecule/nodejs.8/converge.yml @@ -0,0 +1,21 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.nodejs + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/nodejs/tests/0106_install.8.goss.yml b/molecule/nodejs.8/goss/default.yml.j2 similarity index 100% rename from roles/nodejs/tests/0106_install.8.goss.yml rename to molecule/nodejs.8/goss/default.yml.j2 diff --git a/molecule/nodejs.8/molecule.yml b/molecule/nodejs.8/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/nodejs.8/prepare.yml b/molecule/nodejs.8/prepare.yml new file mode 100644 index 000000000..8f03b0957 --- /dev/null +++ b/molecule/nodejs.8/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - nodejs@nodesource_8 diff --git a/molecule/nodejs.9/converge.yml b/molecule/nodejs.9/converge.yml new file mode 100644 index 000000000..2fb565436 --- /dev/null +++ b/molecule/nodejs.9/converge.yml @@ -0,0 +1,21 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.nodejs + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/nodejs/tests/0107_install.9.goss.yml b/molecule/nodejs.9/goss/default.yml.j2 similarity index 100% rename from roles/nodejs/tests/0107_install.9.goss.yml rename to molecule/nodejs.9/goss/default.yml.j2 diff --git a/molecule/nodejs.9/molecule.yml b/molecule/nodejs.9/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/nodejs.9/prepare.yml b/molecule/nodejs.9/prepare.yml new file mode 100644 index 000000000..10f46d6e6 --- /dev/null +++ b/molecule/nodejs.9/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - nodejs@nodesource_9 diff --git a/molecule/npm/converge.yml b/molecule/npm/converge.yml new file mode 100644 index 000000000..489c45f64 --- /dev/null +++ b/molecule/npm/converge.yml @@ -0,0 +1,27 @@ +--- + +############ +# Packages # +############ + +- name: Packages + tags: [packages] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.npm + vars: + manala_npm_packages: + - is-positive + - user-home + - package: negative-zero + state: absent + - package: negative-zero + state: present + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/packages.yml.j2') }}" diff --git a/roles/npm/tests/0100_packages.goss.yml b/molecule/npm/goss/packages.yml.j2 similarity index 100% rename from roles/npm/tests/0100_packages.goss.yml rename to molecule/npm/goss/packages.yml.j2 diff --git a/molecule/npm/molecule.yml b/molecule/npm/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/npm/prepare.yml b/molecule/npm/prepare.yml new file mode 100644 index 000000000..b1e656004 --- /dev/null +++ b/molecule/npm/prepare.yml @@ -0,0 +1,14 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - nodejs@nodesource_16 + - name: NodeJS + import_role: + name: manala.roles.nodejs diff --git a/molecule/ntp/converge.yml b/molecule/ntp/converge.yml new file mode 100644 index 000000000..5aec6b95e --- /dev/null +++ b/molecule/ntp/converge.yml @@ -0,0 +1,19 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.ntp + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/ntp/goss/default.yml.j2 b/molecule/ntp/goss/default.yml.j2 new file mode 100644 index 000000000..1d43deed2 --- /dev/null +++ b/molecule/ntp/goss/default.yml.j2 @@ -0,0 +1,10 @@ +--- + +package: + ntp: + installed: true + +service: + ntp: + enabled: true + running: true diff --git a/molecule/ntp/molecule.yml b/molecule/ntp/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/ohmyzsh/converge.yml b/molecule/ohmyzsh/converge.yml new file mode 100644 index 000000000..143d14c02 --- /dev/null +++ b/molecule/ohmyzsh/converge.yml @@ -0,0 +1,179 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.ohmyzsh + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +################# +# Custom Themes # +################# + +- name: Custom Themes + tags: [custom_themes] + hosts: debian + vars: + tests_dir: /molecule/ohmyzsh/custom_themes + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.ohmyzsh + tasks_from: custom_themes + vars: + manala_ohmyzsh_custom_themes_exclusive: false + manala_ohmyzsh_custom_themes_dir: "{{ tests_dir }}/default" + manala_ohmyzsh_custom_themes_defaults: {} + manala_ohmyzsh_custom_themes: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.ohmyzsh + tasks_from: custom_themes + vars: + manala_ohmyzsh_custom_themes_exclusive: false + manala_ohmyzsh_custom_themes_dir: "{{ tests_dir }}/defaults" + manala_ohmyzsh_custom_themes_defaults: + template: fixtures/template.j2 + manala_ohmyzsh_custom_themes: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.ohmyzsh + tasks_from: custom_themes + vars: + manala_ohmyzsh_custom_themes_exclusive: true + manala_ohmyzsh_custom_themes_dir: "{{ tests_dir }}/exclusive" + manala_ohmyzsh_custom_themes_defaults: {} + manala_ohmyzsh_custom_themes: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/custom_themes.yml.j2') }}" + +######### +# Users # +######### + +- name: Users + tags: [users] + hosts: debian + vars: + tests_dir: /molecule/ohmyzsh/users + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ + ['dict', 'content', 'template', 'flatten', 'state_present_implicit', 'state_present', 'state_absent', 'state_ignore'] + | product(['absent', 'directory']) + }}" + - name: Users + user: + name: "{{ item }}" + loop: [user_dict, user_content, user_template, user_flatten, user_state_present_implicit, user_state_present, user_state_absent, user_state_ignore] + - block: + - name: Role + import_role: + name: manala.roles.ohmyzsh + tasks_from: users + vars: + manala_ohmyzsh_users: + # Dict + - user: user_dict + dir: "{{ tests_dir }}/dict" + config: + foo: ~ + bar: true + baz: false + qux: foo + quux: 123 + corge: [foo, bar, baz] + # Content + - user: user_content + dir: "{{ tests_dir }}/content" + config: | + Content + # Template + - user: user_template + dir: "{{ tests_dir }}/template" + template: fixtures/template.j2 + # Flatten + - + - user: user_flatten + dir: "{{ tests_dir }}/flatten" + # State + - user: user_state_present_implicit + dir: "{{ tests_dir }}/state_present_implicit" + - user: user_state_present + dir: "{{ tests_dir }}/state_present" + state: present + - user: user_state_absent + dir: "{{ tests_dir }}/state_absent" + state: absent + - user: user_state_ignore + dir: "{{ tests_dir }}/state_ignore" + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/users.yml.j2') }}" diff --git a/molecule/ohmyzsh/fixtures/template.j2 b/molecule/ohmyzsh/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/ohmyzsh/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/ohmyzsh/fixtures/template_file.j2 b/molecule/ohmyzsh/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/ohmyzsh/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/ohmyzsh/goss/custom_themes.yml.j2 b/molecule/ohmyzsh/goss/custom_themes.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/ohmyzsh/goss/custom_themes.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/ohmyzsh/goss/default.yml.j2 b/molecule/ohmyzsh/goss/default.yml.j2 new file mode 100644 index 000000000..f8eddb5d8 --- /dev/null +++ b/molecule/ohmyzsh/goss/default.yml.j2 @@ -0,0 +1,15 @@ +--- + +file: + {{ manala_ohmyzsh_dir }}: + exists: true + filetype: directory + owner: root + group: root + mode: "0755" + +command: + git --git-dir={{ manala_ohmyzsh_dir }}/.git --work-tree={{ manala_ohmyzsh_dir }} status: + exit-status: 0 + stdout: + - On branch master diff --git a/molecule/ohmyzsh/goss/users.yml.j2 b/molecule/ohmyzsh/goss/users.yml.j2 new file mode 100644 index 000000000..1574084fa --- /dev/null +++ b/molecule/ohmyzsh/goss/users.yml.j2 @@ -0,0 +1,80 @@ +--- + +file: + + # Dict + {{ tests_dir }}/dict/.zshrc: + exists: true + filetype: file + owner: user_dict + group: user_dict + mode: "0644" + contains: + - 'foo=""' + - 'bar="true"' + - 'baz="false"' + - 'qux="foo"' + - 'quux=123' + - 'corge=(foo bar baz)' + # Content + {{ tests_dir }}/content/.zshrc: + exists: true + filetype: file + owner: user_content + group: user_content + mode: "0644" + contains: + - "/^Content$/" + # Template + {{ tests_dir }}/template/.zshrc: + exists: true + filetype: file + owner: user_template + group: user_template + mode: "0644" + contains: + - "/^Template$/" + # Flatten + {{ tests_dir }}/flatten/.zshrc: + exists: true + filetype: file + owner: user_flatten + group: user_flatten + mode: "0644" + # State + {{ tests_dir }}/state_present_implicit/.zshrc: + exists: true + filetype: file + owner: user_state_present_implicit + group: user_state_present_implicit + mode: "0644" + {{ tests_dir }}/state_present/.zshrc: + exists: true + filetype: file + owner: user_state_present + group: user_state_present + mode: "0644" + {{ tests_dir }}/state_absent/.zshrc: + exists: false + {{ tests_dir }}/state_ignore/.zshrc: + exists: false + +user: + user_dict: + exists: true + shell: /bin/zsh + user_content: + exists: true + shell: /bin/zsh + user_template: + exists: true + shell: /bin/zsh + user_flatten: + exists: true + shell: /bin/zsh + user_state_present_implicit: + exists: true + shell: /bin/zsh + user_state_present: + exists: true + shell: /bin/zsh diff --git a/molecule/ohmyzsh/molecule.yml b/molecule/ohmyzsh/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/ohmyzsh/prepare.yml b/molecule/ohmyzsh/prepare.yml new file mode 100644 index 000000000..eacc3a44b --- /dev/null +++ b/molecule/ohmyzsh/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Packages + apt: + name: [git, zsh] + install_recommends: false + update_cache: true + cache_valid_time: 3600 diff --git a/molecule/pam_ssh_agent_auth/converge.yml b/molecule/pam_ssh_agent_auth/converge.yml new file mode 100644 index 000000000..e16eca388 --- /dev/null +++ b/molecule/pam_ssh_agent_auth/converge.yml @@ -0,0 +1,19 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.pam_ssh_agent_auth + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/pam_ssh_agent_auth/goss/default.yml.j2 b/molecule/pam_ssh_agent_auth/goss/default.yml.j2 new file mode 100644 index 000000000..ba7d1e47d --- /dev/null +++ b/molecule/pam_ssh_agent_auth/goss/default.yml.j2 @@ -0,0 +1,20 @@ +--- + +package: + libpam-ssh-agent-auth: + installed: true + +file: + /etc/sudoers: + exists: true + filetype: file + owner: root + group: root + mode: "0440" + contains: + - "Defaults env_keep += SSH_AUTH_SOCK" + /etc/pam.d/sudo: + exists: true + filetype: file + contains: + - "auth sufficient pam_ssh_agent_auth.so file=%h/.ssh/authorized_keys" diff --git a/molecule/pam_ssh_agent_auth/molecule.yml b/molecule/pam_ssh_agent_auth/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/pam_ssh_agent_auth/prepare.yml b/molecule/pam_ssh_agent_auth/prepare.yml new file mode 100644 index 000000000..a792624d6 --- /dev/null +++ b/molecule/pam_ssh_agent_auth/prepare.yml @@ -0,0 +1,18 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - pam-ssh-agent-auth@manala + when: ansible_distribution_release in ['stretch'] + - name: Packages + apt: + name: [sudo] + install_recommends: false + update_cache: true + cache_valid_time: 3600 diff --git a/molecule/php.5.6/converge.yml b/molecule/php.5.6/converge.yml new file mode 100644 index 000000000..7cfef2179 --- /dev/null +++ b/molecule/php.5.6/converge.yml @@ -0,0 +1,369 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - name: Packages + apt: + name: + - php5.6-cgi # Sapi + - php5.6-tidy # Native extension + - php5.6-apcu # Pecl extension + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - block: + - name: Role + import_role: + name: manala.roles.php + vars: + manala_php_version: 5.6 + manala_php_sapis: + - cli + # Flatten + - + - sapi: fpm + state: present + - sapi: cgi + state: absent + - sapi: phpdbg + state: ignore + manala_php_extensions: + - date # Embedded extension + - calendar # Common extension + - xml # Native extension + - mbstring # Native extension + - memcached # Pecl extension + # Flatten + - + - extension: gd # Native extension + enabled: true + - extension: bz2 # Native extension + enabled: false + - extension: igbinary # Pecl extension + enabled: true + - extension: xdebug # Pecl extension + enabled: false + - extension: curl # Native extension + state: present + - extension: tidy # Native extension + state: absent + - extension: apcu # Pecl extension + state: absent + - extension: bcmath # Native extension + state: ignore + manala_php_applications: + - phpcs + # Flatten + - + - phpunit@4.8.36 + - application: phpunit + version: 5.7.27 + - application: phpcbf + state: ignore + manala_php_blackfire: true + manala_php_blackfire_agent_config_template: blackfire/agent/agent.j2 + manala_php_blackfire_agent_config: + server-id: c74906db-43d3-4c96-ab27-010600321b89 + server-token: 5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + manala_php_blackfire_client_config_template: blackfire/client/.blackfire.ini.j2 + manala_php_blackfire_client_config: + client-id: b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + client-token: e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +############# +# Exclusive # +############# + +- name: Exclusive + tags: [exclusive] + hosts: debian + tasks: + - name: Packages + apt: + name: + - php5.6-cgi # Sapi + - php5.6-tidy # Native extension + - php5.6-apcu # Pecl extension + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - block: + - name: Role + import_role: + name: manala.roles.php + tasks_from: install + vars: + manala_php_version: 5.6 + manala_php_sapis_exclusive: true + manala_php_sapis: + - cli + - fpm + manala_php_extensions_exclusive: true + manala_php_extensions: + - date # Embedded extension + - calendar # Common extension + - xml # Native extension + - memcached # Pecl extension + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/exclusive.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/php/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ [ + 'default/cli/conf.d', 'defaults/cli/conf.d', 'exclusive/cli/conf.d', + 'default/fpm/conf.d', 'defaults/fpm/conf.d', 'exclusive/fpm/conf.d' + ] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/cli/conf.d/state_absent_existing, default/cli/conf.d/state_ignore_existing, + default/fpm/conf.d/state_absent_existing, default/fpm/conf.d/state_ignore_existing, + exclusive/cli/conf.d/existing, exclusive/cli/conf.d/existing_present, exclusive/cli/conf.d/existing_ignore, + exclusive/cli/conf.d/existing_cli, exclusive/cli/conf.d/existing_present_cli, exclusive/cli/conf.d/existing_ignore_cli, + exclusive/fpm/conf.d/existing, exclusive/fpm/conf.d/existing_present, exclusive/fpm/conf.d/existing_ignore, + exclusive/fpm/conf.d/existing_fpm, exclusive/fpm/conf.d/existing_present_fpm, exclusive/fpm/conf.d/existing_ignore_fpm, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.php + tasks_from: configs + vars: + manala_php_version: 5.6 + manala_php_configs_exclusive: false + manala_php_configs_dir: "{{ tests_dir }}/default" + manala_php_configs_defaults: {} + manala_php_configs: + # Dict + - file: dict + config: + memory_limit: 123M + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + manala_php_cli_configs: + # Dict + - file: dict_cli + config: + memory_limit: 255M + manala_php_fpm_configs: + # Dict + - file: dict_fpm + config: + memory_limit: 257M + - name: Role - Defaults + import_role: + name: manala.roles.php + tasks_from: configs + vars: + manala_php_version: 5.6 + manala_php_configs_exclusive: false + manala_php_configs_dir: "{{ tests_dir }}/defaults" + manala_php_configs_defaults: + template: fixtures/template.j2 + manala_php_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + manala_php_cli_configs: + - file: template_cli + manala_php_fpm_configs: + - file: template_fpm + - name: Role - Exclusive + import_role: + name: manala.roles.php + tasks_from: configs + vars: + manala_php_version: 5.6 + manala_php_configs_exclusive: true + manala_php_configs_dir: "{{ tests_dir }}/exclusive" + manala_php_configs_defaults: {} + manala_php_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + manala_php_cli_configs: + - file: existing_present_cli + - file: existing_ignore_cli + state: ignore + - file: ignore_cli + state: ignore + manala_php_fpm_configs: + - file: existing_present_fpm + - file: existing_ignore_fpm + state: ignore + - file: ignore_fpm + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" + +############# +# Fpm Pools # +############# + +- name: Fpm Pools + tags: [fpm_pools] + hosts: debian + vars: + tests_dir: /molecule/php/fpm_pools + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.php + tasks_from: fpm_pools + vars: + manala_php_version: 5.6 + manala_php_sapis: + - fpm + manala_php_fpm_pools_exclusive: false + manala_php_fpm_pools_dir: "{{ tests_dir }}/default" + manala_php_fpm_pools_defaults: {} + manala_php_fpm_pools: + # Dict + - file: dict + config: + www: + user: foo + group: foo + env: + FOO: bar + BAR: 123 + BAZ: 1.2 + QUX: foo=bar + php_admin_value: + memory_limit: 123M + php_value: + display_errors: false + bar: + user: bar + group: bar + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.php + tasks_from: fpm_pools + vars: + manala_php_version: 5.6 + manala_php_sapis: + - fpm + manala_php_fpm_pools_exclusive: false + manala_php_fpm_pools_dir: "{{ tests_dir }}/defaults" + manala_php_fpm_pools_defaults: + template: fixtures/template.j2 + manala_php_fpm_pools: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.php + tasks_from: fpm_pools + vars: + manala_php_version: 5.6 + manala_php_sapis: + - fpm + manala_php_fpm_pools_exclusive: true + manala_php_fpm_pools_dir: "{{ tests_dir }}/exclusive" + manala_php_fpm_pools_defaults: {} + manala_php_fpm_pools: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/fpm_pools.yml.j2') }}" diff --git a/molecule/php.5.6/fixtures/template.j2 b/molecule/php.5.6/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/php.5.6/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/php.5.6/fixtures/template_file.j2 b/molecule/php.5.6/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/php.5.6/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/php.5.6/goss/configs.yml.j2 b/molecule/php.5.6/goss/configs.yml.j2 new file mode 100644 index 000000000..e81a008d7 --- /dev/null +++ b/molecule/php.5.6/goss/configs.yml.j2 @@ -0,0 +1,258 @@ +--- + +file: + # Default - Dict + {{ tests_dir }}/default/cli/conf.d/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "memory_limit = 123M" + {{ tests_dir }}/default/cli/conf.d/dict_cli: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "memory_limit = 255M" + {{ tests_dir }}/default/fpm/conf.d/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "memory_limit = 123M" + {{ tests_dir }}/default/fpm/conf.d/dict_fpm: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "memory_limit = 257M" + # Default - Content + {{ tests_dir }}/default/cli/conf.d/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/default/fpm/conf.d/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/cli/conf.d/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/fpm/conf.d/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/cli/conf.d/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/default/fpm/conf.d/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/cli/conf.d/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/fpm/conf.d/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/cli/conf.d/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/fpm/conf.d/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/cli/conf.d/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/fpm/conf.d/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/cli/conf.d/state_absent: + exists: false + {{ tests_dir }}/default/fpm/conf.d/state_absent: + exists: false + {{ tests_dir }}/default/cli/conf.d/state_absent_existing: + exists: false + {{ tests_dir }}/default/fpm/conf.d/state_absent_existing: + exists: false + {{ tests_dir }}/default/cli/conf.d/state_ignore: + exists: false + {{ tests_dir }}/default/fpm/conf.d/state_ignore: + exists: false + {{ tests_dir }}/default/cli/conf.d/state_ignore_existing: + exists: true + filetype: file + {{ tests_dir }}/default/fpm/conf.d/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/cli/conf.d/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/cli/conf.d/template_cli: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/fpm/conf.d/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/fpm/conf.d/template_fpm: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/cli/conf.d/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/fpm/conf.d/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/cli/conf.d/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/fpm/conf.d/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/cli/conf.d/existing: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/existing_cli: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/existing: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/existing_fpm: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/cli/conf.d/existing_present_cli: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/fpm/conf.d/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/fpm/conf.d/existing_present_fpm: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/cli/conf.d/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/existing_ignore_cli: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/existing_ignore_fpm: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/ignore: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/ignore_cli: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/ignore: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/ignore_fpm: + exists: false diff --git a/molecule/php.5.6/goss/default.yml.j2 b/molecule/php.5.6/goss/default.yml.j2 new file mode 100644 index 000000000..52e0594ca --- /dev/null +++ b/molecule/php.5.6/goss/default.yml.j2 @@ -0,0 +1,143 @@ +--- + +package: + php{{ manala_php_version }}-cli: + installed: true + php{{ manala_php_version }}-fpm: + installed: true + php{{ manala_php_version }}-cgi: + installed: false + php{{ manala_php_version }}-phpdbg: + installed: false + # Extensions + php{{ manala_php_version }}-xml: + installed: true + php{{ manala_php_version }}-mbstring: + installed: true + php-memcached: + installed: false + php{{ manala_php_version }}-memcached: + installed: true + php{{ manala_php_version }}-gd: + installed: true + php{{ manala_php_version }}-bz2: + installed: true + php{{ manala_php_version }}-igbinary: + installed: true + php{{ manala_php_version }}-xdebug: + installed: true + # State + php{{ manala_php_version }}-curl: + installed: true + php{{ manala_php_version }}-tidy: + installed: false + php-apcu: + installed: false + php-bcmath: + installed: false + # Blackfire + blackfire-agent: + installed: true + blackfire-php: + installed: true + +file: + # Extensions + /etc/php/{{ manala_php_version }}/cli/conf.d/20-date.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-calendar.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/calendar.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/15-xml.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/xml.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-mbstring.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/mbstring.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/25-memcached.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/memcached.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-gd.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/gd.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-bz2.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-igbinary.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/igbinary.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-xdebug.ini: + exists: false + # Applications + /usr/local/bin/phpcs: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit_5.7.27: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit: + exists: true + filetype: symlink + linked-to: phpunit_5.7.27 + /usr/local/bin/phpcbf: + exists: false + # Blackfire + /etc/blackfire/agent: + exists: true + contains: + - server-id=c74906db-43d3-4c96-ab27-010600321b89 + - server-token=5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + ~/.blackfire.ini: + exists: true + contains: + - client-id=b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + - client-token=e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + +command: + # Install + php --version: + exit-status: 0 + stdout: + - PHP {{ manala_php_version }}. + # Applications + phpcs --version: + exit-status: 0 + stdout: + - PHP_CodeSniffer version + phpunit --version: + exit-status: 0 + stdout: + - PHPUnit 5.7.27 + phpcbf --version: + exit-status: 127 + # Blackfire + blackfire status: + exit-status: 0 + php -m: + exit-status: 0 + stdout: + - blackfire + php-fpm{{ manala_php_version }} -m: + exit-status: 0 + stdout: + - blackfire + +service: + php{{ manala_php_version }}-fpm: + enabled: true + running: true + # Blackfire + blackfire-agent: + enabled: true + running: true diff --git a/molecule/php.5.6/goss/exclusive.yml.j2 b/molecule/php.5.6/goss/exclusive.yml.j2 new file mode 100644 index 000000000..97a100f43 --- /dev/null +++ b/molecule/php.5.6/goss/exclusive.yml.j2 @@ -0,0 +1,17 @@ +--- + +package: + php{{ manala_php_version }}-cli: + installed: true + php{{ manala_php_version }}-fpm: + installed: true + php{{ manala_php_version }}-cgi: + installed: false + php{{ manala_php_version }}-xml: + installed: true + php{{ manala_php_version }}-memcached: + installed: true + php{{ manala_php_version }}-tidy: + installed: false + php{{ manala_php_version }}-apcu: + installed: false diff --git a/molecule/php.5.6/goss/fpm_pools.yml.j2 b/molecule/php.5.6/goss/fpm_pools.yml.j2 new file mode 100644 index 000000000..be88d2cd4 --- /dev/null +++ b/molecule/php.5.6/goss/fpm_pools.yml.j2 @@ -0,0 +1,119 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[www]" + - "user = foo" + - "group = foo" + - "env[BAR] = 123" + - "env[BAZ] = 1.2" + - "env[FOO] = bar" + - "env[QUX] = foo=bar" + - "php_admin_value[memory_limit] = 123M" + - "php_value[display_errors] = no" + - "[bar]" + - "user = bar" + - "group = bar" + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/php.5.6/molecule.yml b/molecule/php.5.6/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/php.5.6/prepare.yml b/molecule/php.5.6/prepare.yml new file mode 100644 index 000000000..9bbeed14f --- /dev/null +++ b/molecule/php.5.6/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - php@sury_php + manala_apt_repositories: + - blackfire diff --git a/molecule/php.7.0/converge.yml b/molecule/php.7.0/converge.yml new file mode 100644 index 000000000..4defbf359 --- /dev/null +++ b/molecule/php.7.0/converge.yml @@ -0,0 +1,82 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - name: Packages + apt: + name: + - php7.0-cgi # Sapi + - php7.0-tidy # Native extension + - php7.0-apcu # Pecl extension + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - block: + - name: Role + import_role: + name: manala.roles.php + vars: + manala_php_version: 7.0 + manala_php_sapis: + - cli + # Flatten + - + - sapi: fpm + state: present + - sapi: cgi + state: absent + - sapi: phpdbg + state: ignore + manala_php_extensions: + - date # Embedded extension + - calendar # Common extension + - xml # Native extension + - mbstring # Native extension + - memcached # Pecl extension + # Flatten + - + - extension: gd # Native extension + enabled: true + - extension: bz2 # Native extension + enabled: false + - extension: igbinary # Pecl extension + enabled: true + - extension: xdebug # Pecl extension + enabled: false + - extension: curl # Native extension + state: present + - extension: tidy # Native extension + state: absent + - extension: apcu # Pecl extension + state: absent + - extension: bcmath # Native extension + state: ignore + manala_php_applications: + - phpcs + # Flatten + - + - phpunit@4.8.36 + - application: phpunit + version: 6.5.14 + - application: phpcbf + state: ignore + manala_php_blackfire: true + manala_php_blackfire_agent_config_template: blackfire/agent/agent.j2 + manala_php_blackfire_agent_config: + server-id: c74906db-43d3-4c96-ab27-010600321b89 + server-token: 5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + manala_php_blackfire_client_config_template: blackfire/client/.blackfire.ini.j2 + manala_php_blackfire_client_config: + client-id: b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + client-token: e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/php.7.0/goss/default.yml.j2 b/molecule/php.7.0/goss/default.yml.j2 new file mode 100644 index 000000000..32962a56c --- /dev/null +++ b/molecule/php.7.0/goss/default.yml.j2 @@ -0,0 +1,143 @@ +--- + +package: + php{{ manala_php_version }}-cli: + installed: true + php{{ manala_php_version }}-fpm: + installed: true + php{{ manala_php_version }}-cgi: + installed: false + php{{ manala_php_version }}-phpdbg: + installed: false + # Extensions + php{{ manala_php_version }}-xml: + installed: true + php{{ manala_php_version }}-mbstring: + installed: true + php-memcached: + installed: false + php{{ manala_php_version }}-memcached: + installed: true + php{{ manala_php_version }}-gd: + installed: true + php{{ manala_php_version }}-bz2: + installed: true + php{{ manala_php_version }}-igbinary: + installed: true + php{{ manala_php_version }}-xdebug: + installed: true + # State + php{{ manala_php_version }}-curl: + installed: true + php{{ manala_php_version }}-tidy: + installed: false + php-apcu: + installed: false + php-bcmath: + installed: false + # Blackfire + blackfire-agent: + installed: true + blackfire-php: + installed: true + +file: + # Extensions + /etc/php/{{ manala_php_version }}/cli/conf.d/20-date.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-calendar.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/calendar.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/15-xml.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/xml.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-mbstring.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/mbstring.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/25-memcached.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/memcached.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-gd.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/gd.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-bz2.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-igbinary.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/igbinary.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-xdebug.ini: + exists: false + # Applications + /usr/local/bin/phpcs: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit_6.5.14: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit: + exists: true + filetype: symlink + linked-to: phpunit_6.5.14 + /usr/local/bin/phpcbf: + exists: false + # Blackfire + /etc/blackfire/agent: + exists: true + contains: + - server-id=c74906db-43d3-4c96-ab27-010600321b89 + - server-token=5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + ~/.blackfire.ini: + exists: true + contains: + - client-id=b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + - client-token=e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + +command: + # Install + php --version: + exit-status: 0 + stdout: + - PHP {{ manala_php_version }}. + # Applications + phpcs --version: + exit-status: 0 + stdout: + - PHP_CodeSniffer version + phpunit --version: + exit-status: 0 + stdout: + - PHPUnit 6.5.14 + phpcbf --version: + exit-status: 127 + # Blackfire + blackfire status: + exit-status: 0 + php -m: + exit-status: 0 + stdout: + - blackfire + php-fpm{{ manala_php_version }} -m: + exit-status: 0 + stdout: + - blackfire + +service: + php{{ manala_php_version }}-fpm: + enabled: true + running: true + # Blackfire + blackfire-agent: + enabled: true + running: true diff --git a/molecule/php.7.0/molecule.yml b/molecule/php.7.0/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/php.7.0/prepare.yml b/molecule/php.7.0/prepare.yml new file mode 100644 index 000000000..9bbeed14f --- /dev/null +++ b/molecule/php.7.0/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - php@sury_php + manala_apt_repositories: + - blackfire diff --git a/molecule/php.7.1/converge.yml b/molecule/php.7.1/converge.yml new file mode 100644 index 000000000..c238de5c6 --- /dev/null +++ b/molecule/php.7.1/converge.yml @@ -0,0 +1,82 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - name: Packages + apt: + name: + - php7.1-cgi # Sapi + - php7.1-tidy # Native extension + - php7.1-apcu # Pecl extension + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - block: + - name: Role + import_role: + name: manala.roles.php + vars: + manala_php_version: 7.1 + manala_php_sapis: + - cli + # Flatten + - + - sapi: fpm + state: present + - sapi: cgi + state: absent + - sapi: phpdbg + state: ignore + manala_php_extensions: + - date # Embedded extension + - calendar # Common extension + - xml # Native extension + - mbstring # Native extension + - memcached # Pecl extension + # Flatten + - + - extension: gd # Native extension + enabled: true + - extension: bz2 # Native extension + enabled: false + - extension: igbinary # Pecl extension + enabled: true + - extension: xdebug # Pecl extension + enabled: false + - extension: curl # Native extension + state: present + - extension: tidy # Native extension + state: absent + - extension: apcu # Pecl extension + state: absent + - extension: bcmath # Native extension + state: ignore + manala_php_applications: + - phpcs + # Flatten + - + - phpunit@4.8.36 + - application: phpunit + version: 6.5.14 + - application: phpcbf + state: ignore + manala_php_blackfire: true + manala_php_blackfire_agent_config_template: blackfire/agent/agent.j2 + manala_php_blackfire_agent_config: + server-id: c74906db-43d3-4c96-ab27-010600321b89 + server-token: 5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + manala_php_blackfire_client_config_template: blackfire/client/.blackfire.ini.j2 + manala_php_blackfire_client_config: + client-id: b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + client-token: e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/php.7.1/goss/default.yml.j2 b/molecule/php.7.1/goss/default.yml.j2 new file mode 100644 index 000000000..32962a56c --- /dev/null +++ b/molecule/php.7.1/goss/default.yml.j2 @@ -0,0 +1,143 @@ +--- + +package: + php{{ manala_php_version }}-cli: + installed: true + php{{ manala_php_version }}-fpm: + installed: true + php{{ manala_php_version }}-cgi: + installed: false + php{{ manala_php_version }}-phpdbg: + installed: false + # Extensions + php{{ manala_php_version }}-xml: + installed: true + php{{ manala_php_version }}-mbstring: + installed: true + php-memcached: + installed: false + php{{ manala_php_version }}-memcached: + installed: true + php{{ manala_php_version }}-gd: + installed: true + php{{ manala_php_version }}-bz2: + installed: true + php{{ manala_php_version }}-igbinary: + installed: true + php{{ manala_php_version }}-xdebug: + installed: true + # State + php{{ manala_php_version }}-curl: + installed: true + php{{ manala_php_version }}-tidy: + installed: false + php-apcu: + installed: false + php-bcmath: + installed: false + # Blackfire + blackfire-agent: + installed: true + blackfire-php: + installed: true + +file: + # Extensions + /etc/php/{{ manala_php_version }}/cli/conf.d/20-date.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-calendar.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/calendar.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/15-xml.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/xml.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-mbstring.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/mbstring.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/25-memcached.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/memcached.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-gd.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/gd.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-bz2.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-igbinary.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/igbinary.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-xdebug.ini: + exists: false + # Applications + /usr/local/bin/phpcs: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit_6.5.14: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit: + exists: true + filetype: symlink + linked-to: phpunit_6.5.14 + /usr/local/bin/phpcbf: + exists: false + # Blackfire + /etc/blackfire/agent: + exists: true + contains: + - server-id=c74906db-43d3-4c96-ab27-010600321b89 + - server-token=5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + ~/.blackfire.ini: + exists: true + contains: + - client-id=b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + - client-token=e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + +command: + # Install + php --version: + exit-status: 0 + stdout: + - PHP {{ manala_php_version }}. + # Applications + phpcs --version: + exit-status: 0 + stdout: + - PHP_CodeSniffer version + phpunit --version: + exit-status: 0 + stdout: + - PHPUnit 6.5.14 + phpcbf --version: + exit-status: 127 + # Blackfire + blackfire status: + exit-status: 0 + php -m: + exit-status: 0 + stdout: + - blackfire + php-fpm{{ manala_php_version }} -m: + exit-status: 0 + stdout: + - blackfire + +service: + php{{ manala_php_version }}-fpm: + enabled: true + running: true + # Blackfire + blackfire-agent: + enabled: true + running: true diff --git a/molecule/php.7.1/molecule.yml b/molecule/php.7.1/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/php.7.1/prepare.yml b/molecule/php.7.1/prepare.yml new file mode 100644 index 000000000..9bbeed14f --- /dev/null +++ b/molecule/php.7.1/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - php@sury_php + manala_apt_repositories: + - blackfire diff --git a/molecule/php.7.2/converge.yml b/molecule/php.7.2/converge.yml new file mode 100644 index 000000000..8d5b0309d --- /dev/null +++ b/molecule/php.7.2/converge.yml @@ -0,0 +1,82 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - name: Packages + apt: + name: + - php7.2-cgi # Sapi + - php7.2-tidy # Native extension + - php7.2-apcu # Pecl extension + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - block: + - name: Role + import_role: + name: manala.roles.php + vars: + manala_php_version: 7.2 + manala_php_sapis: + - cli + # Flatten + - + - sapi: fpm + state: present + - sapi: cgi + state: absent + - sapi: phpdbg + state: ignore + manala_php_extensions: + - date # Embedded extension + - calendar # Common extension + - xml # Native extension + - mbstring # Native extension + - memcached # Pecl extension + # Flatten + - + - extension: gd # Native extension + enabled: true + - extension: bz2 # Native extension + enabled: false + - extension: igbinary # Pecl extension + enabled: true + - extension: xdebug # Pecl extension + enabled: false + - extension: curl # Native extension + state: present + - extension: tidy # Native extension + state: absent + - extension: apcu # Pecl extension + state: absent + - extension: bcmath # Native extension + state: ignore + manala_php_applications: + - phpcs + # Flatten + - + - phpunit@4.8.36 + - application: phpunit + version: 6.5.14 + - application: phpcbf + state: ignore + manala_php_blackfire: true + manala_php_blackfire_agent_config_template: blackfire/agent/agent.j2 + manala_php_blackfire_agent_config: + server-id: c74906db-43d3-4c96-ab27-010600321b89 + server-token: 5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + manala_php_blackfire_client_config_template: blackfire/client/.blackfire.ini.j2 + manala_php_blackfire_client_config: + client-id: b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + client-token: e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/php.7.2/goss/default.yml.j2 b/molecule/php.7.2/goss/default.yml.j2 new file mode 100644 index 000000000..32962a56c --- /dev/null +++ b/molecule/php.7.2/goss/default.yml.j2 @@ -0,0 +1,143 @@ +--- + +package: + php{{ manala_php_version }}-cli: + installed: true + php{{ manala_php_version }}-fpm: + installed: true + php{{ manala_php_version }}-cgi: + installed: false + php{{ manala_php_version }}-phpdbg: + installed: false + # Extensions + php{{ manala_php_version }}-xml: + installed: true + php{{ manala_php_version }}-mbstring: + installed: true + php-memcached: + installed: false + php{{ manala_php_version }}-memcached: + installed: true + php{{ manala_php_version }}-gd: + installed: true + php{{ manala_php_version }}-bz2: + installed: true + php{{ manala_php_version }}-igbinary: + installed: true + php{{ manala_php_version }}-xdebug: + installed: true + # State + php{{ manala_php_version }}-curl: + installed: true + php{{ manala_php_version }}-tidy: + installed: false + php-apcu: + installed: false + php-bcmath: + installed: false + # Blackfire + blackfire-agent: + installed: true + blackfire-php: + installed: true + +file: + # Extensions + /etc/php/{{ manala_php_version }}/cli/conf.d/20-date.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-calendar.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/calendar.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/15-xml.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/xml.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-mbstring.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/mbstring.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/25-memcached.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/memcached.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-gd.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/gd.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-bz2.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-igbinary.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/igbinary.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-xdebug.ini: + exists: false + # Applications + /usr/local/bin/phpcs: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit_6.5.14: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit: + exists: true + filetype: symlink + linked-to: phpunit_6.5.14 + /usr/local/bin/phpcbf: + exists: false + # Blackfire + /etc/blackfire/agent: + exists: true + contains: + - server-id=c74906db-43d3-4c96-ab27-010600321b89 + - server-token=5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + ~/.blackfire.ini: + exists: true + contains: + - client-id=b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + - client-token=e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + +command: + # Install + php --version: + exit-status: 0 + stdout: + - PHP {{ manala_php_version }}. + # Applications + phpcs --version: + exit-status: 0 + stdout: + - PHP_CodeSniffer version + phpunit --version: + exit-status: 0 + stdout: + - PHPUnit 6.5.14 + phpcbf --version: + exit-status: 127 + # Blackfire + blackfire status: + exit-status: 0 + php -m: + exit-status: 0 + stdout: + - blackfire + php-fpm{{ manala_php_version }} -m: + exit-status: 0 + stdout: + - blackfire + +service: + php{{ manala_php_version }}-fpm: + enabled: true + running: true + # Blackfire + blackfire-agent: + enabled: true + running: true diff --git a/molecule/php.7.2/molecule.yml b/molecule/php.7.2/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/php.7.2/prepare.yml b/molecule/php.7.2/prepare.yml new file mode 100644 index 000000000..9bbeed14f --- /dev/null +++ b/molecule/php.7.2/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - php@sury_php + manala_apt_repositories: + - blackfire diff --git a/molecule/php.7.3/converge.yml b/molecule/php.7.3/converge.yml new file mode 100644 index 000000000..e4e52310d --- /dev/null +++ b/molecule/php.7.3/converge.yml @@ -0,0 +1,82 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - name: Packages + apt: + name: + - php7.3-cgi # Sapi + - php7.3-tidy # Native extension + - php7.3-apcu # Pecl extension + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - block: + - name: Role + import_role: + name: manala.roles.php + vars: + manala_php_version: 7.3 + manala_php_sapis: + - cli + # Flatten + - + - sapi: fpm + state: present + - sapi: cgi + state: absent + - sapi: phpdbg + state: ignore + manala_php_extensions: + - date # Embedded extension + - calendar # Common extension + - xml # Native extension + - mbstring # Native extension + - memcached # Pecl extension + # Flatten + - + - extension: gd # Native extension + enabled: true + - extension: bz2 # Native extension + enabled: false + - extension: igbinary # Pecl extension + enabled: true + - extension: xdebug # Pecl extension + enabled: false + - extension: curl # Native extension + state: present + - extension: tidy # Native extension + state: absent + - extension: apcu # Pecl extension + state: absent + - extension: bcmath # Native extension + state: ignore + manala_php_applications: + - phpcs + # Flatten + - + - phpunit@4.8.36 + - application: phpunit + version: 6.5.14 + - application: phpcbf + state: ignore + manala_php_blackfire: true + manala_php_blackfire_agent_config_template: blackfire/agent/agent.j2 + manala_php_blackfire_agent_config: + server-id: c74906db-43d3-4c96-ab27-010600321b89 + server-token: 5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + manala_php_blackfire_client_config_template: blackfire/client/.blackfire.ini.j2 + manala_php_blackfire_client_config: + client-id: b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + client-token: e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/php.7.3/goss/default.yml.j2 b/molecule/php.7.3/goss/default.yml.j2 new file mode 100644 index 000000000..f4b9c9e99 --- /dev/null +++ b/molecule/php.7.3/goss/default.yml.j2 @@ -0,0 +1,143 @@ +--- + +package: + php{{ manala_php_version }}-cli: + installed: true + php{{ manala_php_version }}-fpm: + installed: true + php{{ manala_php_version }}-cgi: + installed: false + php{{ manala_php_version }}-phpdbg: + installed: false +# Extensions + php{{ manala_php_version }}-xml: + installed: true + php{{ manala_php_version }}-mbstring: + installed: true + php-memcached: + installed: false + php{{ manala_php_version }}-memcached: + installed: true + php{{ manala_php_version }}-gd: + installed: true + php{{ manala_php_version }}-bz2: + installed: true + php{{ manala_php_version }}-igbinary: + installed: true + php{{ manala_php_version }}-xdebug: + installed: true + # State + php{{ manala_php_version }}-curl: + installed: true + php{{ manala_php_version }}-tidy: + installed: false + php-apcu: + installed: false + php-bcmath: + installed: false + # Blackfire + blackfire-agent: + installed: true + blackfire-php: + installed: true + +file: + # Extensions + /etc/php/{{ manala_php_version }}/cli/conf.d/20-date.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-calendar.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/calendar.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/15-xml.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/xml.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-mbstring.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/mbstring.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/25-memcached.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/memcached.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-gd.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/gd.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-bz2.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-igbinary.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/igbinary.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-xdebug.ini: + exists: false + # Applications + /usr/local/bin/phpcs: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit_6.5.14: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit: + exists: true + filetype: symlink + linked-to: phpunit_6.5.14 + /usr/local/bin/phpcbf: + exists: false + # Blackfire + /etc/blackfire/agent: + exists: true + contains: + - server-id=c74906db-43d3-4c96-ab27-010600321b89 + - server-token=5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + ~/.blackfire.ini: + exists: true + contains: + - client-id=b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + - client-token=e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + +command: + # Install + php --version: + exit-status: 0 + stdout: + - PHP {{ manala_php_version }}. + # Applications + phpcs --version: + exit-status: 0 + stdout: + - PHP_CodeSniffer version + phpunit --version: + exit-status: 0 + stdout: + - PHPUnit 6.5.14 + phpcbf --version: + exit-status: 127 + # Blackfire + blackfire status: + exit-status: 0 + php -m: + exit-status: 0 + stdout: + - blackfire + php-fpm{{ manala_php_version }} -m: + exit-status: 0 + stdout: + - blackfire + +service: + php{{ manala_php_version }}-fpm: + enabled: true + running: true + # Blackfire + blackfire-agent: + enabled: true + running: true diff --git a/molecule/php.7.3/molecule.yml b/molecule/php.7.3/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/php.7.3/prepare.yml b/molecule/php.7.3/prepare.yml new file mode 100644 index 000000000..9bbeed14f --- /dev/null +++ b/molecule/php.7.3/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - php@sury_php + manala_apt_repositories: + - blackfire diff --git a/molecule/php.7.4/converge.yml b/molecule/php.7.4/converge.yml new file mode 100644 index 000000000..8ccdb6082 --- /dev/null +++ b/molecule/php.7.4/converge.yml @@ -0,0 +1,369 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - name: Packages + apt: + name: + - php7.4-cgi # Sapi + - php7.4-tidy # Native extension + - php7.4-apcu # Pecl extension + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - block: + - name: Role + import_role: + name: manala.roles.php + vars: + manala_php_version: 7.4 + manala_php_sapis: + - cli + # Flatten + - + - sapi: fpm + state: present + - sapi: cgi + state: absent + - sapi: phpdbg + state: ignore + manala_php_extensions: + - date # Embedded extension + - calendar # Common extension + - xml # Native extension + - mbstring # Native extension + - memcached # Pecl extension + # Flatten + - + - extension: gd # Native extension + enabled: true + - extension: bz2 # Native extension + enabled: false + - extension: igbinary # Pecl extension + enabled: true + - extension: xdebug # Pecl extension + enabled: false + - extension: curl # Native extension + state: present + - extension: tidy # Native extension + state: absent + - extension: apcu # Pecl extension + state: absent + - extension: bcmath # Native extension + state: ignore + manala_php_applications: + - phpcs + # Flatten + - + - phpunit@4.8.36 + - application: phpunit + version: 6.5.14 + - application: phpcbf + state: ignore + manala_php_blackfire: true + manala_php_blackfire_agent_config_template: blackfire/agent/agent.j2 + manala_php_blackfire_agent_config: + server-id: c74906db-43d3-4c96-ab27-010600321b89 + server-token: 5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + manala_php_blackfire_client_config_template: blackfire/client/.blackfire.ini.j2 + manala_php_blackfire_client_config: + client-id: b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + client-token: e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +############# +# Exclusive # +############# + +- name: Exclusive + tags: [exclusive] + hosts: debian + tasks: + - name: Packages + apt: + name: + - php7.4-cgi # Sapi + - php7.4-tidy # Native extension + - php7.4-apcu # Pecl extension + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - block: + - name: Role + import_role: + name: manala.roles.php + tasks_from: install + vars: + manala_php_version: 7.4 + manala_php_sapis_exclusive: true + manala_php_sapis: + - cli + - fpm + manala_php_extensions_exclusive: true + manala_php_extensions: + - date # Embedded extension + - calendar # Common extension + - xml # Native extension + - memcached # Pecl extension + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/exclusive.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/php/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ [ + 'default/cli/conf.d', 'defaults/cli/conf.d', 'exclusive/cli/conf.d', + 'default/fpm/conf.d', 'defaults/fpm/conf.d', 'exclusive/fpm/conf.d' + ] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/cli/conf.d/state_absent_existing, default/cli/conf.d/state_ignore_existing, + default/fpm/conf.d/state_absent_existing, default/fpm/conf.d/state_ignore_existing, + exclusive/cli/conf.d/existing, exclusive/cli/conf.d/existing_present, exclusive/cli/conf.d/existing_ignore, + exclusive/cli/conf.d/existing_cli, exclusive/cli/conf.d/existing_present_cli, exclusive/cli/conf.d/existing_ignore_cli, + exclusive/fpm/conf.d/existing, exclusive/fpm/conf.d/existing_present, exclusive/fpm/conf.d/existing_ignore, + exclusive/fpm/conf.d/existing_fpm, exclusive/fpm/conf.d/existing_present_fpm, exclusive/fpm/conf.d/existing_ignore_fpm, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.php + tasks_from: configs + vars: + manala_php_version: 7.4 + manala_php_configs_exclusive: false + manala_php_configs_dir: "{{ tests_dir }}/default" + manala_php_configs_defaults: {} + manala_php_configs: + # Dict + - file: dict + config: + memory_limit: 123M + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + manala_php_cli_configs: + # Dict + - file: dict_cli + config: + memory_limit: 255M + manala_php_fpm_configs: + # Dict + - file: dict_fpm + config: + memory_limit: 257M + - name: Role - Defaults + import_role: + name: manala.roles.php + tasks_from: configs + vars: + manala_php_version: 7.4 + manala_php_configs_exclusive: false + manala_php_configs_dir: "{{ tests_dir }}/defaults" + manala_php_configs_defaults: + template: fixtures/template.j2 + manala_php_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + manala_php_cli_configs: + - file: template_cli + manala_php_fpm_configs: + - file: template_fpm + - name: Role - Exclusive + import_role: + name: manala.roles.php + tasks_from: configs + vars: + manala_php_version: 7.4 + manala_php_configs_exclusive: true + manala_php_configs_dir: "{{ tests_dir }}/exclusive" + manala_php_configs_defaults: {} + manala_php_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + manala_php_cli_configs: + - file: existing_present_cli + - file: existing_ignore_cli + state: ignore + - file: ignore_cli + state: ignore + manala_php_fpm_configs: + - file: existing_present_fpm + - file: existing_ignore_fpm + state: ignore + - file: ignore_fpm + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" + +############# +# Fpm Pools # +############# + +- name: Fpm Pools + tags: [fpm_pools] + hosts: debian + vars: + tests_dir: /molecule/php/fpm_pools + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.php + tasks_from: fpm_pools + vars: + manala_php_version: 7.4 + manala_php_sapis: + - fpm + manala_php_fpm_pools_exclusive: false + manala_php_fpm_pools_dir: "{{ tests_dir }}/default" + manala_php_fpm_pools_defaults: {} + manala_php_fpm_pools: + # Dict + - file: dict + config: + www: + user: foo + group: foo + env: + FOO: bar + BAR: 123 + BAZ: 1.2 + QUX: foo=bar + php_admin_value: + memory_limit: 123M + php_value: + display_errors: false + bar: + user: bar + group: bar + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.php + tasks_from: fpm_pools + vars: + manala_php_version: 7.4 + manala_php_sapis: + - fpm + manala_php_fpm_pools_exclusive: false + manala_php_fpm_pools_dir: "{{ tests_dir }}/defaults" + manala_php_fpm_pools_defaults: + template: fixtures/template.j2 + manala_php_fpm_pools: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.php + tasks_from: fpm_pools + vars: + manala_php_version: 7.4 + manala_php_sapis: + - fpm + manala_php_fpm_pools_exclusive: true + manala_php_fpm_pools_dir: "{{ tests_dir }}/exclusive" + manala_php_fpm_pools_defaults: {} + manala_php_fpm_pools: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/fpm_pools.yml.j2') }}" diff --git a/molecule/php.7.4/fixtures/template.j2 b/molecule/php.7.4/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/php.7.4/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/php.7.4/fixtures/template_file.j2 b/molecule/php.7.4/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/php.7.4/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/php.7.4/goss/configs.yml.j2 b/molecule/php.7.4/goss/configs.yml.j2 new file mode 100644 index 000000000..e81a008d7 --- /dev/null +++ b/molecule/php.7.4/goss/configs.yml.j2 @@ -0,0 +1,258 @@ +--- + +file: + # Default - Dict + {{ tests_dir }}/default/cli/conf.d/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "memory_limit = 123M" + {{ tests_dir }}/default/cli/conf.d/dict_cli: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "memory_limit = 255M" + {{ tests_dir }}/default/fpm/conf.d/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "memory_limit = 123M" + {{ tests_dir }}/default/fpm/conf.d/dict_fpm: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "memory_limit = 257M" + # Default - Content + {{ tests_dir }}/default/cli/conf.d/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/default/fpm/conf.d/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/cli/conf.d/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/fpm/conf.d/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/cli/conf.d/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/default/fpm/conf.d/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/cli/conf.d/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/fpm/conf.d/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/cli/conf.d/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/fpm/conf.d/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/cli/conf.d/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/fpm/conf.d/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/cli/conf.d/state_absent: + exists: false + {{ tests_dir }}/default/fpm/conf.d/state_absent: + exists: false + {{ tests_dir }}/default/cli/conf.d/state_absent_existing: + exists: false + {{ tests_dir }}/default/fpm/conf.d/state_absent_existing: + exists: false + {{ tests_dir }}/default/cli/conf.d/state_ignore: + exists: false + {{ tests_dir }}/default/fpm/conf.d/state_ignore: + exists: false + {{ tests_dir }}/default/cli/conf.d/state_ignore_existing: + exists: true + filetype: file + {{ tests_dir }}/default/fpm/conf.d/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/cli/conf.d/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/cli/conf.d/template_cli: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/fpm/conf.d/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/fpm/conf.d/template_fpm: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/cli/conf.d/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/fpm/conf.d/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/cli/conf.d/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/fpm/conf.d/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/cli/conf.d/existing: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/existing_cli: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/existing: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/existing_fpm: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/cli/conf.d/existing_present_cli: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/fpm/conf.d/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/fpm/conf.d/existing_present_fpm: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/cli/conf.d/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/existing_ignore_cli: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/existing_ignore_fpm: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/ignore: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/ignore_cli: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/ignore: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/ignore_fpm: + exists: false diff --git a/molecule/php.7.4/goss/default.yml.j2 b/molecule/php.7.4/goss/default.yml.j2 new file mode 100644 index 000000000..32962a56c --- /dev/null +++ b/molecule/php.7.4/goss/default.yml.j2 @@ -0,0 +1,143 @@ +--- + +package: + php{{ manala_php_version }}-cli: + installed: true + php{{ manala_php_version }}-fpm: + installed: true + php{{ manala_php_version }}-cgi: + installed: false + php{{ manala_php_version }}-phpdbg: + installed: false + # Extensions + php{{ manala_php_version }}-xml: + installed: true + php{{ manala_php_version }}-mbstring: + installed: true + php-memcached: + installed: false + php{{ manala_php_version }}-memcached: + installed: true + php{{ manala_php_version }}-gd: + installed: true + php{{ manala_php_version }}-bz2: + installed: true + php{{ manala_php_version }}-igbinary: + installed: true + php{{ manala_php_version }}-xdebug: + installed: true + # State + php{{ manala_php_version }}-curl: + installed: true + php{{ manala_php_version }}-tidy: + installed: false + php-apcu: + installed: false + php-bcmath: + installed: false + # Blackfire + blackfire-agent: + installed: true + blackfire-php: + installed: true + +file: + # Extensions + /etc/php/{{ manala_php_version }}/cli/conf.d/20-date.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-calendar.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/calendar.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/15-xml.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/xml.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-mbstring.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/mbstring.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/25-memcached.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/memcached.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-gd.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/gd.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-bz2.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-igbinary.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/igbinary.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-xdebug.ini: + exists: false + # Applications + /usr/local/bin/phpcs: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit_6.5.14: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit: + exists: true + filetype: symlink + linked-to: phpunit_6.5.14 + /usr/local/bin/phpcbf: + exists: false + # Blackfire + /etc/blackfire/agent: + exists: true + contains: + - server-id=c74906db-43d3-4c96-ab27-010600321b89 + - server-token=5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + ~/.blackfire.ini: + exists: true + contains: + - client-id=b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + - client-token=e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + +command: + # Install + php --version: + exit-status: 0 + stdout: + - PHP {{ manala_php_version }}. + # Applications + phpcs --version: + exit-status: 0 + stdout: + - PHP_CodeSniffer version + phpunit --version: + exit-status: 0 + stdout: + - PHPUnit 6.5.14 + phpcbf --version: + exit-status: 127 + # Blackfire + blackfire status: + exit-status: 0 + php -m: + exit-status: 0 + stdout: + - blackfire + php-fpm{{ manala_php_version }} -m: + exit-status: 0 + stdout: + - blackfire + +service: + php{{ manala_php_version }}-fpm: + enabled: true + running: true + # Blackfire + blackfire-agent: + enabled: true + running: true diff --git a/molecule/php.7.4/goss/exclusive.yml.j2 b/molecule/php.7.4/goss/exclusive.yml.j2 new file mode 100644 index 000000000..97a100f43 --- /dev/null +++ b/molecule/php.7.4/goss/exclusive.yml.j2 @@ -0,0 +1,17 @@ +--- + +package: + php{{ manala_php_version }}-cli: + installed: true + php{{ manala_php_version }}-fpm: + installed: true + php{{ manala_php_version }}-cgi: + installed: false + php{{ manala_php_version }}-xml: + installed: true + php{{ manala_php_version }}-memcached: + installed: true + php{{ manala_php_version }}-tidy: + installed: false + php{{ manala_php_version }}-apcu: + installed: false diff --git a/molecule/php.7.4/goss/fpm_pools.yml.j2 b/molecule/php.7.4/goss/fpm_pools.yml.j2 new file mode 100644 index 000000000..be88d2cd4 --- /dev/null +++ b/molecule/php.7.4/goss/fpm_pools.yml.j2 @@ -0,0 +1,119 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[www]" + - "user = foo" + - "group = foo" + - "env[BAR] = 123" + - "env[BAZ] = 1.2" + - "env[FOO] = bar" + - "env[QUX] = foo=bar" + - "php_admin_value[memory_limit] = 123M" + - "php_value[display_errors] = no" + - "[bar]" + - "user = bar" + - "group = bar" + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/php.7.4/molecule.yml b/molecule/php.7.4/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/php.7.4/prepare.yml b/molecule/php.7.4/prepare.yml new file mode 100644 index 000000000..9bbeed14f --- /dev/null +++ b/molecule/php.7.4/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - php@sury_php + manala_apt_repositories: + - blackfire diff --git a/molecule/php.8.0/converge.yml b/molecule/php.8.0/converge.yml new file mode 100644 index 000000000..000654ee8 --- /dev/null +++ b/molecule/php.8.0/converge.yml @@ -0,0 +1,82 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - name: Packages + apt: + name: + - php8.0-cgi # Sapi + - php8.0-tidy # Native extension + - php8.0-apcu # Pecl extension + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - block: + - name: Role + import_role: + name: manala.roles.php + vars: + manala_php_version: 8.0 + manala_php_sapis: + - cli + # Flatten + - + - sapi: fpm + state: present + - sapi: cgi + state: absent + - sapi: phpdbg + state: ignore + manala_php_extensions: + - date # Embedded extension + - calendar # Common extension + - xml # Native extension + - mbstring # Native extension + - memcached # Pecl extension + # Flatten + - + - extension: gd # Native extension + enabled: true + - extension: bz2 # Native extension + enabled: false + - extension: igbinary # Pecl extension + enabled: true + - extension: xdebug # Pecl extension + enabled: false + - extension: curl # Native extension + state: present + - extension: tidy # Native extension + state: absent + - extension: apcu # Pecl extension + state: absent + - extension: bcmath # Native extension + state: ignore + manala_php_applications: + - phpcs + # Flatten + - + - phpunit@4.8.36 + - application: phpunit + version: 9.5.10 + - application: phpcbf + state: ignore + manala_php_blackfire: true + manala_php_blackfire_agent_config_template: blackfire/agent/agent.j2 + manala_php_blackfire_agent_config: + server-id: c74906db-43d3-4c96-ab27-010600321b89 + server-token: 5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + manala_php_blackfire_client_config_template: blackfire/client/.blackfire.ini.j2 + manala_php_blackfire_client_config: + client-id: b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + client-token: e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/molecule/php.8.0/goss/default.yml.j2 b/molecule/php.8.0/goss/default.yml.j2 new file mode 100644 index 000000000..35fe42df2 --- /dev/null +++ b/molecule/php.8.0/goss/default.yml.j2 @@ -0,0 +1,143 @@ +--- + +package: + php{{ manala_php_version }}-cli: + installed: true + php{{ manala_php_version }}-fpm: + installed: true + php{{ manala_php_version }}-cgi: + installed: false + php{{ manala_php_version }}-phpdbg: + installed: false + # Extensions + php{{ manala_php_version }}-xml: + installed: true + php{{ manala_php_version }}-mbstring: + installed: true + php-memcached: + installed: false + php{{ manala_php_version }}-memcached: + installed: true + php{{ manala_php_version }}-gd: + installed: true + php{{ manala_php_version }}-bz2: + installed: true + php{{ manala_php_version }}-igbinary: + installed: true + php{{ manala_php_version }}-xdebug: + installed: true + # State + php{{ manala_php_version }}-curl: + installed: true + php{{ manala_php_version }}-tidy: + installed: false + php-apcu: + installed: false + php-bcmath: + installed: false + # Blackfire + blackfire-agent: + installed: true + blackfire-php: + installed: true + +file: + # Extensions + /etc/php/{{ manala_php_version }}/cli/conf.d/20-date.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-calendar.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/calendar.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/15-xml.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/xml.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-mbstring.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/mbstring.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/25-memcached.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/memcached.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-gd.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/gd.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-bz2.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-igbinary.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/igbinary.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-xdebug.ini: + exists: false + # Applications + /usr/local/bin/phpcs: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit_9.5.10: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit: + exists: true + filetype: symlink + linked-to: phpunit_9.5.10 + /usr/local/bin/phpcbf: + exists: false + # Blackfire + /etc/blackfire/agent: + exists: true + contains: + - server-id=c74906db-43d3-4c96-ab27-010600321b89 + - server-token=5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + ~/.blackfire.ini: + exists: true + contains: + - client-id=b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + - client-token=e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + +command: + # Install + php --version: + exit-status: 0 + stdout: + - PHP {{ manala_php_version }}. + # Applications + phpcs --version: + exit-status: 0 + stdout: + - PHP_CodeSniffer version + phpunit --version: + exit-status: 0 + stdout: + - PHPUnit 9.5.10 + phpcbf --version: + exit-status: 127 + # Blackfire + blackfire status: + exit-status: 0 + php -m: + exit-status: 0 + stdout: + - blackfire + php-fpm{{ manala_php_version }} -m: + exit-status: 0 + stdout: + - blackfire + +service: + php{{ manala_php_version }}-fpm: + enabled: true + running: true + # Blackfire + blackfire-agent: + enabled: true + running: true diff --git a/molecule/php.8.0/molecule.yml b/molecule/php.8.0/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/php.8.0/prepare.yml b/molecule/php.8.0/prepare.yml new file mode 100644 index 000000000..9bbeed14f --- /dev/null +++ b/molecule/php.8.0/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - php@sury_php + manala_apt_repositories: + - blackfire diff --git a/molecule/php.8.1/converge.yml b/molecule/php.8.1/converge.yml new file mode 100644 index 000000000..f66a337ba --- /dev/null +++ b/molecule/php.8.1/converge.yml @@ -0,0 +1,369 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - name: Packages + apt: + name: + - php8.1-cgi # Sapi + - php8.1-tidy # Native extension + - php8.1-apcu # Pecl extension + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - block: + - name: Role + import_role: + name: manala.roles.php + vars: + manala_php_version: 8.1 + manala_php_sapis: + - cli + # Flatten + - + - sapi: fpm + state: present + - sapi: cgi + state: absent + - sapi: phpdbg + state: ignore + manala_php_extensions: + - date # Embedded extension + - calendar # Common extension + - xml # Native extension + - mbstring # Native extension + - memcached # Pecl extension + # Flatten + - + - extension: gd # Native extension + enabled: true + - extension: bz2 # Native extension + enabled: false + - extension: igbinary # Pecl extension + enabled: true + - extension: xdebug # Pecl extension + enabled: false + - extension: curl # Native extension + state: present + - extension: tidy # Native extension + state: absent + - extension: apcu # Pecl extension + state: absent + - extension: bcmath # Native extension + state: ignore + manala_php_applications: + - phpcs + # Flatten + - + - phpunit@4.8.36 + - application: phpunit + version: 9.5.10 + - application: phpcbf + state: ignore + manala_php_blackfire: true + manala_php_blackfire_agent_config_template: blackfire/agent/agent.j2 + manala_php_blackfire_agent_config: + server-id: c74906db-43d3-4c96-ab27-010600321b89 + server-token: 5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + manala_php_blackfire_client_config_template: blackfire/client/.blackfire.ini.j2 + manala_php_blackfire_client_config: + client-id: b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + client-token: e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +############# +# Exclusive # +############# + +- name: Exclusive + tags: [exclusive] + hosts: debian + tasks: + - name: Packages + apt: + name: + - php8.1-cgi # Sapi + - php8.1-tidy # Native extension + - php8.1-apcu # Pecl extension + install_recommends: false + update_cache: true + cache_valid_time: 3600 + - block: + - name: Role + import_role: + name: manala.roles.php + tasks_from: install + vars: + manala_php_version: 8.1 + manala_php_sapis_exclusive: true + manala_php_sapis: + - cli + - fpm + manala_php_extensions_exclusive: true + manala_php_extensions: + - date # Embedded extension + - calendar # Common extension + - xml # Native extension + - memcached # Pecl extension + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/exclusive.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/php/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ [ + 'default/cli/conf.d', 'defaults/cli/conf.d', 'exclusive/cli/conf.d', + 'default/fpm/conf.d', 'defaults/fpm/conf.d', 'exclusive/fpm/conf.d' + ] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/cli/conf.d/state_absent_existing, default/cli/conf.d/state_ignore_existing, + default/fpm/conf.d/state_absent_existing, default/fpm/conf.d/state_ignore_existing, + exclusive/cli/conf.d/existing, exclusive/cli/conf.d/existing_present, exclusive/cli/conf.d/existing_ignore, + exclusive/cli/conf.d/existing_cli, exclusive/cli/conf.d/existing_present_cli, exclusive/cli/conf.d/existing_ignore_cli, + exclusive/fpm/conf.d/existing, exclusive/fpm/conf.d/existing_present, exclusive/fpm/conf.d/existing_ignore, + exclusive/fpm/conf.d/existing_fpm, exclusive/fpm/conf.d/existing_present_fpm, exclusive/fpm/conf.d/existing_ignore_fpm, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.php + tasks_from: configs + vars: + manala_php_version: 8.1 + manala_php_configs_exclusive: false + manala_php_configs_dir: "{{ tests_dir }}/default" + manala_php_configs_defaults: {} + manala_php_configs: + # Dict + - file: dict + config: + memory_limit: 123M + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + manala_php_cli_configs: + # Dict + - file: dict_cli + config: + memory_limit: 255M + manala_php_fpm_configs: + # Dict + - file: dict_fpm + config: + memory_limit: 257M + - name: Role - Defaults + import_role: + name: manala.roles.php + tasks_from: configs + vars: + manala_php_version: 8.1 + manala_php_configs_exclusive: false + manala_php_configs_dir: "{{ tests_dir }}/defaults" + manala_php_configs_defaults: + template: fixtures/template.j2 + manala_php_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + manala_php_cli_configs: + - file: template_cli + manala_php_fpm_configs: + - file: template_fpm + - name: Role - Exclusive + import_role: + name: manala.roles.php + tasks_from: configs + vars: + manala_php_version: 8.1 + manala_php_configs_exclusive: true + manala_php_configs_dir: "{{ tests_dir }}/exclusive" + manala_php_configs_defaults: {} + manala_php_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + manala_php_cli_configs: + - file: existing_present_cli + - file: existing_ignore_cli + state: ignore + - file: ignore_cli + state: ignore + manala_php_fpm_configs: + - file: existing_present_fpm + - file: existing_ignore_fpm + state: ignore + - file: ignore_fpm + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" + +############# +# Fpm Pools # +############# + +- name: Fpm Pools + tags: [fpm_pools] + hosts: debian + vars: + tests_dir: /molecule/php/fpm_pools + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.php + tasks_from: fpm_pools + vars: + manala_php_version: 8.1 + manala_php_sapis: + - fpm + manala_php_fpm_pools_exclusive: false + manala_php_fpm_pools_dir: "{{ tests_dir }}/default" + manala_php_fpm_pools_defaults: {} + manala_php_fpm_pools: + # Dict + - file: dict + config: + www: + user: foo + group: foo + env: + FOO: bar + BAR: 123 + BAZ: 1.2 + QUX: foo=bar + php_admin_value: + memory_limit: 123M + php_value: + display_errors: false + bar: + user: bar + group: bar + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.php + tasks_from: fpm_pools + vars: + manala_php_version: 8.1 + manala_php_sapis: + - fpm + manala_php_fpm_pools_exclusive: false + manala_php_fpm_pools_dir: "{{ tests_dir }}/defaults" + manala_php_fpm_pools_defaults: + template: fixtures/template.j2 + manala_php_fpm_pools: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.php + tasks_from: fpm_pools + vars: + manala_php_version: 8.1 + manala_php_sapis: + - fpm + manala_php_fpm_pools_exclusive: true + manala_php_fpm_pools_dir: "{{ tests_dir }}/exclusive" + manala_php_fpm_pools_defaults: {} + manala_php_fpm_pools: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/fpm_pools.yml.j2') }}" diff --git a/molecule/php.8.1/fixtures/template.j2 b/molecule/php.8.1/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/php.8.1/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/php.8.1/fixtures/template_file.j2 b/molecule/php.8.1/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/php.8.1/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/php.8.1/goss/configs.yml.j2 b/molecule/php.8.1/goss/configs.yml.j2 new file mode 100644 index 000000000..e81a008d7 --- /dev/null +++ b/molecule/php.8.1/goss/configs.yml.j2 @@ -0,0 +1,258 @@ +--- + +file: + # Default - Dict + {{ tests_dir }}/default/cli/conf.d/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "memory_limit = 123M" + {{ tests_dir }}/default/cli/conf.d/dict_cli: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "memory_limit = 255M" + {{ tests_dir }}/default/fpm/conf.d/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "memory_limit = 123M" + {{ tests_dir }}/default/fpm/conf.d/dict_fpm: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "memory_limit = 257M" + # Default - Content + {{ tests_dir }}/default/cli/conf.d/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/default/fpm/conf.d/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/cli/conf.d/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/fpm/conf.d/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/cli/conf.d/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/default/fpm/conf.d/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/cli/conf.d/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/fpm/conf.d/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/cli/conf.d/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/fpm/conf.d/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/cli/conf.d/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/fpm/conf.d/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/cli/conf.d/state_absent: + exists: false + {{ tests_dir }}/default/fpm/conf.d/state_absent: + exists: false + {{ tests_dir }}/default/cli/conf.d/state_absent_existing: + exists: false + {{ tests_dir }}/default/fpm/conf.d/state_absent_existing: + exists: false + {{ tests_dir }}/default/cli/conf.d/state_ignore: + exists: false + {{ tests_dir }}/default/fpm/conf.d/state_ignore: + exists: false + {{ tests_dir }}/default/cli/conf.d/state_ignore_existing: + exists: true + filetype: file + {{ tests_dir }}/default/fpm/conf.d/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/cli/conf.d/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/cli/conf.d/template_cli: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/fpm/conf.d/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/fpm/conf.d/template_fpm: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/cli/conf.d/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/fpm/conf.d/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/cli/conf.d/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/fpm/conf.d/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/cli/conf.d/existing: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/existing_cli: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/existing: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/existing_fpm: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/cli/conf.d/existing_present_cli: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/fpm/conf.d/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/fpm/conf.d/existing_present_fpm: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/cli/conf.d/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/existing_ignore_cli: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/existing_ignore_fpm: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/ignore: + exists: false + {{ tests_dir }}/exclusive/cli/conf.d/ignore_cli: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/ignore: + exists: false + {{ tests_dir }}/exclusive/fpm/conf.d/ignore_fpm: + exists: false diff --git a/molecule/php.8.1/goss/default.yml.j2 b/molecule/php.8.1/goss/default.yml.j2 new file mode 100644 index 000000000..35fe42df2 --- /dev/null +++ b/molecule/php.8.1/goss/default.yml.j2 @@ -0,0 +1,143 @@ +--- + +package: + php{{ manala_php_version }}-cli: + installed: true + php{{ manala_php_version }}-fpm: + installed: true + php{{ manala_php_version }}-cgi: + installed: false + php{{ manala_php_version }}-phpdbg: + installed: false + # Extensions + php{{ manala_php_version }}-xml: + installed: true + php{{ manala_php_version }}-mbstring: + installed: true + php-memcached: + installed: false + php{{ manala_php_version }}-memcached: + installed: true + php{{ manala_php_version }}-gd: + installed: true + php{{ manala_php_version }}-bz2: + installed: true + php{{ manala_php_version }}-igbinary: + installed: true + php{{ manala_php_version }}-xdebug: + installed: true + # State + php{{ manala_php_version }}-curl: + installed: true + php{{ manala_php_version }}-tidy: + installed: false + php-apcu: + installed: false + php-bcmath: + installed: false + # Blackfire + blackfire-agent: + installed: true + blackfire-php: + installed: true + +file: + # Extensions + /etc/php/{{ manala_php_version }}/cli/conf.d/20-date.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-calendar.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/calendar.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/15-xml.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/xml.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-mbstring.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/mbstring.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/25-memcached.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/memcached.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-gd.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/gd.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-bz2.ini: + exists: false + /etc/php/{{ manala_php_version }}/cli/conf.d/20-igbinary.ini: + exists: true + filetype: symlink + linked-to: /etc/php/{{ manala_php_version }}/mods-available/igbinary.ini + /etc/php/{{ manala_php_version }}/cli/conf.d/20-xdebug.ini: + exists: false + # Applications + /usr/local/bin/phpcs: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit_9.5.10: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + /usr/local/bin/phpunit: + exists: true + filetype: symlink + linked-to: phpunit_9.5.10 + /usr/local/bin/phpcbf: + exists: false + # Blackfire + /etc/blackfire/agent: + exists: true + contains: + - server-id=c74906db-43d3-4c96-ab27-010600321b89 + - server-token=5b78cc7fea3b766ff4ea470178b502c829c09d58ebdc20252e0337db804000e2 + ~/.blackfire.ini: + exists: true + contains: + - client-id=b7bf7d2d-c8c1-4354-82bf-aa403afbc3b3 + - client-token=e7d9ca7e486b67d1f2d9b764fb383340fbd374e20daefa747e8a4fd690d83e7b + +command: + # Install + php --version: + exit-status: 0 + stdout: + - PHP {{ manala_php_version }}. + # Applications + phpcs --version: + exit-status: 0 + stdout: + - PHP_CodeSniffer version + phpunit --version: + exit-status: 0 + stdout: + - PHPUnit 9.5.10 + phpcbf --version: + exit-status: 127 + # Blackfire + blackfire status: + exit-status: 0 + php -m: + exit-status: 0 + stdout: + - blackfire + php-fpm{{ manala_php_version }} -m: + exit-status: 0 + stdout: + - blackfire + +service: + php{{ manala_php_version }}-fpm: + enabled: true + running: true + # Blackfire + blackfire-agent: + enabled: true + running: true diff --git a/molecule/php.8.1/goss/exclusive.yml.j2 b/molecule/php.8.1/goss/exclusive.yml.j2 new file mode 100644 index 000000000..97a100f43 --- /dev/null +++ b/molecule/php.8.1/goss/exclusive.yml.j2 @@ -0,0 +1,17 @@ +--- + +package: + php{{ manala_php_version }}-cli: + installed: true + php{{ manala_php_version }}-fpm: + installed: true + php{{ manala_php_version }}-cgi: + installed: false + php{{ manala_php_version }}-xml: + installed: true + php{{ manala_php_version }}-memcached: + installed: true + php{{ manala_php_version }}-tidy: + installed: false + php{{ manala_php_version }}-apcu: + installed: false diff --git a/molecule/php.8.1/goss/fpm_pools.yml.j2 b/molecule/php.8.1/goss/fpm_pools.yml.j2 new file mode 100644 index 000000000..be88d2cd4 --- /dev/null +++ b/molecule/php.8.1/goss/fpm_pools.yml.j2 @@ -0,0 +1,119 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[www]" + - "user = foo" + - "group = foo" + - "env[BAR] = 123" + - "env[BAZ] = 1.2" + - "env[FOO] = bar" + - "env[QUX] = foo=bar" + - "php_admin_value[memory_limit] = 123M" + - "php_value[display_errors] = no" + - "[bar]" + - "user = bar" + - "group = bar" + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/php.8.1/molecule.yml b/molecule/php.8.1/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/php.8.1/prepare.yml b/molecule/php.8.1/prepare.yml new file mode 100644 index 000000000..9bbeed14f --- /dev/null +++ b/molecule/php.8.1/prepare.yml @@ -0,0 +1,13 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - php@sury_php + manala_apt_repositories: + - blackfire diff --git a/molecule/postgresql.9.4/converge.yml b/molecule/postgresql.9.4/converge.yml new file mode 100644 index 000000000..4d250e3f6 --- /dev/null +++ b/molecule/postgresql.9.4/converge.yml @@ -0,0 +1,85 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.postgresql + vars: + manala_postgresql_version: 9.4 + manala_postgresql_config_hba: | + # Database administrative login by Unix domain socket + local all postgres peer + # Trust all IPv4 local connections + host all all 127.0.0.1/32 trust + manala_postgresql_roles: + - role: foo + password: ~ + attributes: ['SUPERUSER'] + manala_postgresql_databases: + - database: bar + manala_postgresql_privileges: + - role: foo + database: bar + privileges: + - ALL + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/postgresql/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Content + import_role: + name: manala.roles.postgresql + tasks_from: config + vars: + manala_postgresql_version: 9.4 + manala_postgresql_config_file: "{{ tests_dir }}/content" + manala_postgresql_config_template: ~ + manala_postgresql_config: | + Content + manala_postgresql_config_hba_file: "{{ tests_dir }}/content_hba" + manala_postgresql_config_hba_template: ~ + manala_postgresql_config_hba: | + Content + - name: Role - Template + import_role: + name: manala.roles.postgresql + tasks_from: config + vars: + manala_postgresql_version: 9.4 + manala_postgresql_config_file: "{{ tests_dir }}/template" + manala_postgresql_config_template: fixtures/template.j2 + manala_postgresql_config: ~ + manala_postgresql_config_hba_file: "{{ tests_dir }}/template_hba" + manala_postgresql_config_hba_template: fixtures/template.j2 + manala_postgresql_config_hba: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" diff --git a/molecule/postgresql.9.4/fixtures/template.j2 b/molecule/postgresql.9.4/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/postgresql.9.4/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/postgresql.9.4/goss/config.yml.j2 b/molecule/postgresql.9.4/goss/config.yml.j2 new file mode 100644 index 000000000..d08d12108 --- /dev/null +++ b/molecule/postgresql.9.4/goss/config.yml.j2 @@ -0,0 +1,35 @@ +--- + +file: + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/content_hba: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/template_hba: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/postgresql.9.4/goss/default.yml.j2 b/molecule/postgresql.9.4/goss/default.yml.j2 new file mode 100644 index 000000000..566954472 --- /dev/null +++ b/molecule/postgresql.9.4/goss/default.yml.j2 @@ -0,0 +1,34 @@ +--- + +package: + postgresql-9.4: + installed: true + postgresql-contrib-9.4: + installed: true + +command: + psql --version: + exit-status: 0 + stdout: + - psql (PostgreSQL) 9.4 + +service: + postgresql: + enabled: true + running: true + +command: + psql --host=127.0.0.1 --username=postgres --command="\du": + exit-status: 0 + stdout: + - foo | Superuser | {} + psql --host=127.0.0.1 --username=postgres --command="\l": + exit-status: 0 + stdout: + - bar | postgres | UTF8 | C.UTF-8 | C.UTF-8 | + psql --host=127.0.0.1 --username=postgres --command="\l": + exit-status: 0 + stdout: + - "bar | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =Tc/postgres +" + - " | | | | | postgres=CTc/postgres+" + - " | | | | | foo=CTc/postgres" diff --git a/molecule/postgresql.9.4/molecule.yml b/molecule/postgresql.9.4/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/postgresql.9.4/prepare.yml b/molecule/postgresql.9.4/prepare.yml new file mode 100644 index 000000000..0d80f0b0b --- /dev/null +++ b/molecule/postgresql.9.4/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - postgresql@postgresql diff --git a/molecule/proftpd/converge.yml b/molecule/proftpd/converge.yml new file mode 100644 index 000000000..5087c648a --- /dev/null +++ b/molecule/proftpd/converge.yml @@ -0,0 +1,163 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.proftpd + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/proftpd/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.proftpd + tasks_from: configs + vars: + manala_proftpd_configs_exclusive: false + manala_proftpd_configs_dir: "{{ tests_dir }}/default" + manala_proftpd_configs_defaults: {} + manala_proftpd_configs: + # Dict + - file: dict + config: + ServerName: Manala ProFTPD Server + DefaultRoot: "~" + - name: Role - Default + import_role: + name: manala.roles.proftpd + tasks_from: configs + vars: + manala_proftpd_configs_exclusive: false + manala_proftpd_configs_dir: "{{ tests_dir }}/default" + manala_proftpd_configs_defaults: {} + manala_proftpd_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.proftpd + tasks_from: configs + vars: + manala_proftpd_configs_exclusive: false + manala_proftpd_configs_dir: "{{ tests_dir }}/defaults" + manala_proftpd_configs_defaults: + template: fixtures/template.j2 + manala_proftpd_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.proftpd + tasks_from: configs + vars: + manala_proftpd_configs_exclusive: true + manala_proftpd_configs_dir: "{{ tests_dir }}/exclusive" + manala_proftpd_configs_defaults: {} + manala_proftpd_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" + +######### +# Users # +######### + +- name: Users + tags: [users] + hosts: debian + vars: + tests_dir: /molecule/proftpd/users + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + name: manala.roles.proftpd + tasks_from: users + vars: + manala_proftpd_users_file: "{{ tests_dir }}/ftpd.passwd" + manala_proftpd_users: + - name: user-1 + password: $1$Z4eVi1jp$IQJdkHh28GGFbq9oSQR/b0 # mkpasswd --method=md5 --salt=Z4eVi1jp testpasswordproftpd + home: "{{ tests_dir }}/user1" + shell: /bin/false + - name: user-2 + password: $1$Z4eVi1jp$o4qLQc670sqyO2CKWzYBm1 # mkpasswd --method=md5 --salt=Z4eVi1jp proftpdtestpassword + home: "{{ tests_dir }}/user2" + mode: "0755" + uid: 0 + gid: 0 + shell: /bin/false + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/users.yml.j2') }}" diff --git a/molecule/proftpd/fixtures/template.j2 b/molecule/proftpd/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/proftpd/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/proftpd/fixtures/template_file.j2 b/molecule/proftpd/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/proftpd/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/proftpd/goss/configs.yml.j2 b/molecule/proftpd/goss/configs.yml.j2 new file mode 100644 index 000000000..2205e37c8 --- /dev/null +++ b/molecule/proftpd/goss/configs.yml.j2 @@ -0,0 +1,108 @@ +--- + +file: + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - ServerName Manala ProFTPD Server + - DefaultRoot ~ + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/roles/proftpd/tests/0000_default.goss.yml b/molecule/proftpd/goss/default.yml.j2 similarity index 100% rename from roles/proftpd/tests/0000_default.goss.yml rename to molecule/proftpd/goss/default.yml.j2 diff --git a/molecule/proftpd/goss/users.yml.j2 b/molecule/proftpd/goss/users.yml.j2 new file mode 100644 index 000000000..f19f083bf --- /dev/null +++ b/molecule/proftpd/goss/users.yml.j2 @@ -0,0 +1,22 @@ +--- + +file: + {{ tests_dir }}/ftpd.passwd: + exists: true + filetype: file + owner: root + group: root + mode: "0600" + contains: + - "user-1:$1$Z4eVi1jp$IQJdkHh28GGFbq9oSQR/b0:108:100::{{ tests_dir }}/user1:/bin/false" + - "user-2:$1$Z4eVi1jp$o4qLQc670sqyO2CKWzYBm1:0:0::{{ tests_dir }}/user2:/bin/false" + {{ tests_dir }}/user1: + exists: true + filetype: directory + mode: "0700" + {{ tests_dir }}/user2: + exists: true + filetype: directory + mode: "0755" + owner: root + group: root diff --git a/molecule/proftpd/molecule.yml b/molecule/proftpd/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/redis.3.2/converge.yml b/molecule/redis.3.2/converge.yml new file mode 100644 index 000000000..b26360f66 --- /dev/null +++ b/molecule/redis.3.2/converge.yml @@ -0,0 +1,22 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + tasks: + - block: + - name: Role + import_role: + name: manala.roles.redis + vars: + manala_redis_sentinel: true + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/redis/tests/0001_default.3.2.goss.yml b/molecule/redis.3.2/goss/default.yml.j2 similarity index 100% rename from roles/redis/tests/0001_default.3.2.goss.yml rename to molecule/redis.3.2/goss/default.yml.j2 diff --git a/molecule/redis.3.2/molecule.yml b/molecule/redis.3.2/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/redis.5.0/converge.yml b/molecule/redis.5.0/converge.yml new file mode 100644 index 000000000..08000880b --- /dev/null +++ b/molecule/redis.5.0/converge.yml @@ -0,0 +1,23 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.stretch + - debian.buster + tasks: + - block: + - name: Role + import_role: + name: manala.roles.redis + vars: + manala_redis_sentinel: true + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/redis/tests/0002_default.5.0.goss.yml b/molecule/redis.5.0/goss/default.yml.j2 similarity index 100% rename from roles/redis/tests/0002_default.5.0.goss.yml rename to molecule/redis.5.0/goss/default.yml.j2 diff --git a/molecule/redis.5.0/molecule.yml b/molecule/redis.5.0/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/redis.5.0/prepare.yml b/molecule/redis.5.0/prepare.yml new file mode 100644 index 000000000..dd9f8a335 --- /dev/null +++ b/molecule/redis.5.0/prepare.yml @@ -0,0 +1,14 @@ +--- + +- hosts: + - debian.stretch + - debian.buster + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - redis@backports + when: ansible_distribution_release in ['stretch'] diff --git a/molecule/redis.6.0/converge.yml b/molecule/redis.6.0/converge.yml new file mode 100644 index 000000000..ca05950fc --- /dev/null +++ b/molecule/redis.6.0/converge.yml @@ -0,0 +1,97 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: + - debian.buster + - debian.bullseye + tasks: + - block: + - name: Role + import_role: + name: manala.roles.redis + vars: + manala_redis_sentinel: true + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: + - debian.buster + - debian.bullseye + vars: + tests_dir: /molecule/redis/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - name: Create sentinel_config_dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/dict-sentinel" + state: touch + - block: + - name: Role + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.redis + vars: + manala_redis_sentinel: true + manala_redis_sentinel_config: + sentinel monitor: foo 1.2.3.4 6379 2 + sentinel down-after-milliseconds: foo 1234 + - name: Role - Dict + import_role: + name: manala.roles.redis + tasks_from: config + vars: + manala_redis_server_config_file: "{{ tests_dir }}/dict-server" + manala_redis_server_config_template: ~ + manala_redis_server_config: + include: + - /foo/bar.conf + - /foo/baz.conf + port: 1234 + manala_redis_sentinel_config_file: "{{ tests_dir }}/dict-sentinel" + manala_redis_sentinel_config: + sentinel monitor: foo 1.2.3.4 6379 2 + sentinel down-after-milliseconds: foo 1234 + - name: Role - Content + import_role: + name: manala.roles.redis + tasks_from: config + vars: + # manala_redis_sentinel_config_file: ~ + manala_redis_sentinel_config: {} + manala_redis_server_config_file: "{{ tests_dir }}/content-server" + manala_redis_server_config_template: ~ + manala_redis_server_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.redis + tasks_from: config + vars: + # manala_redis_sentinel_config_file: ~ + manala_redis_sentinel_config: {} + manala_redis_server_config_file: "{{ tests_dir }}/template-server" + manala_redis_server_config_template: fixtures/template.j2 + manala_redis_server_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" diff --git a/molecule/redis.6.0/fixtures/template.j2 b/molecule/redis.6.0/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/redis.6.0/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/redis.6.0/goss/config.yml.j2 b/molecule/redis.6.0/goss/config.yml.j2 new file mode 100644 index 000000000..f727f9bbe --- /dev/null +++ b/molecule/redis.6.0/goss/config.yml.j2 @@ -0,0 +1,35 @@ +--- + +file: + {{ tests_dir }}/dict-server: + exists: true + filetype: file + owner: redis + group: redis + mode: "0640" + contains: + - "include /foo/bar.conf" + - "include /foo/baz.conf" + - "port 1234" + {{ tests_dir }}/dict-sentinel: + exists: true + filetype: file + contains: + - "sentinel monitor foo 1.2.3.4 6379 2" + - "sentinel down-after-milliseconds foo 1234" + {{ tests_dir }}/content-server: + exists: true + filetype: file + owner: redis + group: redis + mode: "0640" + contains: + - "/^Content$/" + {{ tests_dir }}/template-server: + exists: true + filetype: file + owner: redis + group: redis + mode: "0640" + contains: + - "/^Template$/" diff --git a/roles/redis/tests/0003_default.6.0.goss.yml b/molecule/redis.6.0/goss/default.yml.j2 similarity index 100% rename from roles/redis/tests/0003_default.6.0.goss.yml rename to molecule/redis.6.0/goss/default.yml.j2 diff --git a/molecule/redis.6.0/molecule.yml b/molecule/redis.6.0/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/redis.6.0/prepare.yml b/molecule/redis.6.0/prepare.yml new file mode 100644 index 000000000..392fbf657 --- /dev/null +++ b/molecule/redis.6.0/prepare.yml @@ -0,0 +1,14 @@ +--- + +- hosts: + - debian.buster + - debian.bullseye + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - redis@backports + when: ansible_distribution_release in ['buster'] diff --git a/molecule/rsyslog/converge.yml b/molecule/rsyslog/converge.yml new file mode 100644 index 000000000..277403b08 --- /dev/null +++ b/molecule/rsyslog/converge.yml @@ -0,0 +1,158 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.rsyslog + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/rsyslog/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + name: manala.roles.rsyslog + tasks_from: config + vars: + manala_rsyslog_config_file: "{{ tests_dir }}/dict" + manala_rsyslog_config_template: ~ + manala_rsyslog_config: + $ModLoad imklog: false + $FileOwner: foo + - name: Role - Content + import_role: + name: manala.roles.rsyslog + tasks_from: config + vars: + manala_rsyslog_config_file: "{{ tests_dir }}/content" + manala_rsyslog_config_template: ~ + manala_rsyslog_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.rsyslog + tasks_from: config + vars: + manala_rsyslog_config_file: "{{ tests_dir }}/template" + manala_rsyslog_config_template: fixtures/template.j2 + manala_rsyslog_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/rsyslog/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.rsyslog + tasks_from: configs + vars: + manala_rsyslog_configs_exclusive: false + manala_rsyslog_configs_dir: "{{ tests_dir }}/default" + manala_rsyslog_configs_defaults: {} + manala_rsyslog_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.rsyslog + tasks_from: configs + vars: + manala_rsyslog_configs_exclusive: false + manala_rsyslog_configs_dir: "{{ tests_dir }}/defaults" + manala_rsyslog_configs_defaults: + template: fixtures/template.j2 + manala_rsyslog_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.rsyslog + tasks_from: configs + vars: + manala_rsyslog_configs_exclusive: true + manala_rsyslog_configs_dir: "{{ tests_dir }}/exclusive" + manala_rsyslog_configs_defaults: {} + manala_rsyslog_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" diff --git a/molecule/rsyslog/fixtures/template.j2 b/molecule/rsyslog/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/rsyslog/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/rsyslog/fixtures/template_file.j2 b/molecule/rsyslog/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/rsyslog/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/rsyslog/goss/config.yml.j2 b/molecule/rsyslog/goss/config.yml.j2 new file mode 100644 index 000000000..59e8bd071 --- /dev/null +++ b/molecule/rsyslog/goss/config.yml.j2 @@ -0,0 +1,28 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - #$ModLoad imklog + - $FileOwner foo + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/rsyslog/goss/configs.yml.j2 b/molecule/rsyslog/goss/configs.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/rsyslog/goss/configs.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/roles/rsyslog/tests/0000_default.goss.yml b/molecule/rsyslog/goss/default.yml.j2 similarity index 100% rename from roles/rsyslog/tests/0000_default.goss.yml rename to molecule/rsyslog/goss/default.yml.j2 diff --git a/molecule/rsyslog/molecule.yml b/molecule/rsyslog/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/sensu_go/converge.yml b/molecule/sensu_go/converge.yml new file mode 100644 index 000000000..bf9857371 --- /dev/null +++ b/molecule/sensu_go/converge.yml @@ -0,0 +1,54 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.sensu_go + vars: + manala_sensu_go_backend: true + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/sensu_go/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + name: manala.roles.sensu_go + vars: + manala_sensu_go_agent_config_file: "{{ tests_dir }}/dict-agent" + manala_sensu_go_agent_config: + backend-url: ['ws://127.0.0.1:8081'] + manala_sensu_go_backend_config_file: "{{ tests_dir }}/dict-backend" + manala_sensu_go_backend: true + manala_sensu_go_backend_config: + state-dir: "/tmp" + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" diff --git a/molecule/sensu_go/goss/config.yml.j2 b/molecule/sensu_go/goss/config.yml.j2 new file mode 100644 index 000000000..201f98fe5 --- /dev/null +++ b/molecule/sensu_go/goss/config.yml.j2 @@ -0,0 +1,21 @@ +--- + +file: + "{{ tests_dir }}/dict-agent": + exists: true + filetype: file + owner: sensu + group: sensu + mode: "0640" + contains: + - "backend-url:" + - "ws://127.0.0.1:8081" + + "{{ tests_dir }}/dict-backend": + exists: true + filetype: file + owner: sensu + group: sensu + mode: "0640" + contains: + - "state-dir: /tmp" diff --git a/molecule/sensu_go/goss/default.yml.j2 b/molecule/sensu_go/goss/default.yml.j2 new file mode 100644 index 000000000..4e17a479b --- /dev/null +++ b/molecule/sensu_go/goss/default.yml.j2 @@ -0,0 +1,17 @@ +--- + +package: + sensu-go-agent: + installed: true + sensu-go-cli: + installed: true + sensu-go-backend: + installed: true + +service: + sensu-backend: + enabled: true + running: true + sensu-agent: + enabled: true + running: true diff --git a/molecule/sensu_go/molecule.yml b/molecule/sensu_go/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/sensu_go/prepare.yml b/molecule/sensu_go/prepare.yml new file mode 100644 index 000000000..91de44a86 --- /dev/null +++ b/molecule/sensu_go/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - sensu-go@manala diff --git a/molecule/shorewall/converge.yml b/molecule/shorewall/converge.yml new file mode 100644 index 000000000..77153e7b7 --- /dev/null +++ b/molecule/shorewall/converge.yml @@ -0,0 +1,194 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.shorewall + vars: + manala_shorewall_configs: + - file: policy + config: | + net all DROP + all all REJECT + - file: interfaces + config: | + net NET_IF detect tcpflags,nosmurfs,bridge + - file: zones + config: | + net ipv4 + fw firewall + always: + - name: Flush handlers + meta: flush_handlers + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/shorewall/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.shorewall + vars: + manala_shorewall_configs: + - file: policy + config: | + net all DROP + all all REJECT + - file: interfaces + config: | + net NET_IF detect tcpflags,nosmurfs,bridge + - file: zones + config: | + net ipv4 + fw firewall + - name: Role - Default + import_role: + name: manala.roles.shorewall + tasks_from: configs + vars: + manala_shorewall_configs_exclusive: false + manala_shorewall_configs_dir: "{{ tests_dir }}/default" + manala_shorewall_configs_defaults: {} + manala_shorewall_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.shorewall + tasks_from: configs + vars: + manala_shorewall_configs_exclusive: false + manala_shorewall_configs_dir: "{{ tests_dir }}/defaults" + manala_shorewall_configs_defaults: + template: fixtures/template.j2 + manala_shorewall_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.shorewall + tasks_from: configs + vars: + manala_shorewall_configs_exclusive: true + manala_shorewall_configs_dir: "{{ tests_dir }}/exclusive" + manala_shorewall_configs_defaults: {} + manala_shorewall_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Flush handlers + meta: flush_handlers + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/shorewall/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.shorewall + vars: + manala_shorewall_configs: + - file: policy + config: | + net all DROP + all all REJECT + - file: interfaces + config: | + net NET_IF detect tcpflags,nosmurfs,bridge + - file: zones + config: | + net ipv4 + fw firewall + - name: Role - Dict + import_role: + name: manala.roles.shorewall + tasks_from: config + vars: + manala_shorewall_config_file: "{{ tests_dir }}/dict" + manala_shorewall_config: + LOG_MARTIANS: "No" + IP_FORWARDING: "On" + MULTICAST: "Yes" + always: + - name: Flush handlers + meta: flush_handlers + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" diff --git a/molecule/shorewall/fixtures/template.j2 b/molecule/shorewall/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/shorewall/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/shorewall/fixtures/template_file.j2 b/molecule/shorewall/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/shorewall/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/shorewall/goss/config.yml.j2 b/molecule/shorewall/goss/config.yml.j2 new file mode 100644 index 000000000..67d2e5735 --- /dev/null +++ b/molecule/shorewall/goss/config.yml.j2 @@ -0,0 +1,13 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - LOG_MARTIANS=No + - IP_FORWARDING=On + - MULTICAST=Yes diff --git a/molecule/shorewall/goss/configs.yml.j2 b/molecule/shorewall/goss/configs.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/shorewall/goss/configs.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/shorewall/goss/default.yml.j2 b/molecule/shorewall/goss/default.yml.j2 new file mode 100644 index 000000000..4b1923b4d --- /dev/null +++ b/molecule/shorewall/goss/default.yml.j2 @@ -0,0 +1,10 @@ +--- + +package: + shorewall: + installed: true + +service: + shorewall: + enabled: false + running: true diff --git a/molecule/shorewall/molecule.yml b/molecule/shorewall/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/sqlite/converge.yml b/molecule/sqlite/converge.yml new file mode 100644 index 000000000..4835e4d77 --- /dev/null +++ b/molecule/sqlite/converge.yml @@ -0,0 +1,19 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.sqlite + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/sqlite/tests/0100_install.goss.yml b/molecule/sqlite/goss/default.yml.j2 similarity index 100% rename from roles/sqlite/tests/0100_install.goss.yml rename to molecule/sqlite/goss/default.yml.j2 diff --git a/molecule/sqlite/molecule.yml b/molecule/sqlite/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/ssh/converge.yml b/molecule/ssh/converge.yml new file mode 100644 index 000000000..9bc7c0d16 --- /dev/null +++ b/molecule/ssh/converge.yml @@ -0,0 +1,114 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.ssh + vars: + manala_ssh_known_hosts: "{{ manala_ssh_known_hosts_patterns }}" + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Client # +########## + +- name: Default + tags: [client] + hosts: debian + tasks: + - name: Packages absent + apt: + name: + - openssh-server + - openssh-client + state: absent + - block: + - name: Role + import_role: + name: manala.roles.ssh + vars: + manala_ssh_server: false + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/client.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/ssh/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.ssh + vars: + manala_ssh_server_config_file: "{{ tests_dir }}/dict-server" + manala_ssh_server_config_template: ~ + manala_ssh_server_config: + foo: ~ + bar: true + baz: false + qux: foo + quux: 123 + corge: [foo, bar, baz] + grault: + foo: bar + bar: 123 + manala_ssh_client_config_file: "{{ tests_dir }}/dict-client" + manala_ssh_client_config_template: ~ + manala_ssh_client_config: + foo: bar + - name: Role - Content + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.ssh + vars: + manala_ssh_server_config_file: "{{ tests_dir }}/content-server" + manala_ssh_server_config_template: ~ + manala_ssh_server_config: | + Content + manala_ssh_client_config_file: "{{ tests_dir }}/content-client" + manala_ssh_client_config_template: ~ + manala_ssh_client_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.ssh + tasks_from: config + vars: + manala_ssh_server_config_file: "{{ tests_dir }}/template-server" + manala_ssh_server_config_template: fixtures/template.j2 + manala_ssh_server_config: ~ + manala_ssh_client_config_file: "{{ tests_dir }}/template-client" + manala_ssh_client_config_template: fixtures/template.j2 + manala_ssh_client_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" diff --git a/molecule/ssh/fixtures/template.j2 b/molecule/ssh/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/ssh/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/ssh/goss/client.yml.j2 b/molecule/ssh/goss/client.yml.j2 new file mode 100644 index 000000000..c3d9abca4 --- /dev/null +++ b/molecule/ssh/goss/client.yml.j2 @@ -0,0 +1,7 @@ +--- + +package: + openssh-server: + installed: false + openssh-client: + installed: true diff --git a/molecule/ssh/goss/config.yml.j2 b/molecule/ssh/goss/config.yml.j2 new file mode 100644 index 000000000..24d643a55 --- /dev/null +++ b/molecule/ssh/goss/config.yml.j2 @@ -0,0 +1,67 @@ +--- + +file: + {{ tests_dir }}: + exists: true + filetype: directory + owner: root + group: root + mode: "0755" + {{ tests_dir }}/dict-server: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "foo none" + - "bar yes" + - "baz no" + - "qux foo" + - "quux 123" + - "corge foo" + - "corge bar" + - "corge baz" + - "grault" + - " foo bar" + - " bar 123" + {{ tests_dir }}/dict-client: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "foo bar" + {{ tests_dir }}/content-server: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/content-client: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template-server: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/template-client: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/ssh/goss/default.yml.j2 b/molecule/ssh/goss/default.yml.j2 new file mode 100644 index 000000000..a3a92dede --- /dev/null +++ b/molecule/ssh/goss/default.yml.j2 @@ -0,0 +1,19 @@ +--- + +package: + openssh-server: + installed: true + openssh-client: + installed: true + +service: + ssh: + enabled: true + running: true + +file: + /etc/ssh/ssh_known_hosts: + exists: true + contains: + - github.com ssh-rsa + diff --git a/molecule/ssh/molecule.yml b/molecule/ssh/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/sudo/converge.yml b/molecule/sudo/converge.yml new file mode 100644 index 000000000..a2edd796f --- /dev/null +++ b/molecule/sudo/converge.yml @@ -0,0 +1,109 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.sudo + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Sudoers # +########### + +- name: Sudoers + tags: [sudoers] + hosts: debian + vars: + tests_dir: /molecule/sudo/sudoers + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.sudo + tasks_from: sudoers + vars: + manala_sudo_sudoers_exclusive: false + manala_sudo_sudoers_dir: "{{ tests_dir }}/default" + manala_sudo_sudoers_defaults: {} + manala_sudo_sudoers: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.sudo + tasks_from: sudoers + vars: + manala_sudo_sudoers_exclusive: false + manala_sudo_sudoers_dir: "{{ tests_dir }}/defaults" + manala_sudo_sudoers_defaults: + template: fixtures/template.j2 + manala_sudo_sudoers: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.sudo + tasks_from: sudoers + vars: + manala_sudo_sudoers_exclusive: true + manala_sudo_sudoers_dir: "{{ tests_dir }}/exclusive" + manala_sudo_sudoers_defaults: {} + manala_sudo_sudoers: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/sudoers.yml.j2') }}" diff --git a/molecule/sudo/fixtures/template.j2 b/molecule/sudo/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/sudo/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/sudo/fixtures/template_file.j2 b/molecule/sudo/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/sudo/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/roles/sudo/tests/0000_default.goss.yml b/molecule/sudo/goss/default.yml.j2 similarity index 100% rename from roles/sudo/tests/0000_default.goss.yml rename to molecule/sudo/goss/default.yml.j2 diff --git a/molecule/sudo/goss/sudoers.yml.j2 b/molecule/sudo/goss/sudoers.yml.j2 new file mode 100644 index 000000000..bb2affab5 --- /dev/null +++ b/molecule/sudo/goss/sudoers.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0440" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0440" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0440" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0440" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0440" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0440" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0440" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0440" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0440" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0440" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/sudo/molecule.yml b/molecule/sudo/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/supervisor/converge.yml b/molecule/supervisor/converge.yml new file mode 100644 index 000000000..9802a7754 --- /dev/null +++ b/molecule/supervisor/converge.yml @@ -0,0 +1,171 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.supervisor + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/supervisor/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.supervisor + vars: + manala_supervisor_config_file: "{{ tests_dir }}/dict" + manala_supervisor_config_template: ~ + manala_supervisor_config: + unix_http_server: + file: /tmp/supervisor.sock + chmod: "0700" + chown: nobody:nogroup + supervisord: + logfile: /var/log/supervisord.log + - name: Role - Content + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.supervisor + vars: + manala_supervisor_config_file: "{{ tests_dir }}/content" + manala_supervisor_config_template: ~ + manala_supervisor_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.supervisor + tasks_from: config + vars: + manala_supervisor_config_file: "{{ tests_dir }}/template" + manala_supervisor_config_template: fixtures/template.j2 + manala_supervisor_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/supervisor/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.supervisor + tasks_from: configs + vars: + manala_supervisor_configs_exclusive: false + manala_supervisor_configs_dir: "{{ tests_dir }}/default" + manala_supervisor_configs_defaults: {} + manala_supervisor_configs: + # Dict + - file: dict + config: + unix_http_server: + file: /tmp/supervisor.sock + chmod: "0700" + chown: nobody:nogroup + supervisord: + logfile: /var/log/supervisord.log + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.supervisor + tasks_from: configs + vars: + manala_supervisor_configs_exclusive: false + manala_supervisor_configs_dir: "{{ tests_dir }}/defaults" + manala_supervisor_configs_defaults: + template: fixtures/template.j2 + manala_supervisor_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.supervisor + tasks_from: configs + vars: + manala_supervisor_configs_exclusive: true + manala_supervisor_configs_dir: "{{ tests_dir }}/exclusive" + manala_supervisor_configs_defaults: {} + manala_supervisor_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" diff --git a/molecule/supervisor/fixtures/template.j2 b/molecule/supervisor/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/supervisor/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/supervisor/fixtures/template_file.j2 b/molecule/supervisor/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/supervisor/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/supervisor/goss/config.yml.j2 b/molecule/supervisor/goss/config.yml.j2 new file mode 100644 index 000000000..ea4c41be6 --- /dev/null +++ b/molecule/supervisor/goss/config.yml.j2 @@ -0,0 +1,32 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[unix_http_server]" + - "file=/tmp/supervisor.sock" + - "chmod=0700" + - "chown=nobody:nogroup" + - "[supervisord]" + - "logfile=/var/log/supervisord.log" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/supervisor/goss/configs.yml.j2 b/molecule/supervisor/goss/configs.yml.j2 new file mode 100644 index 000000000..c9eaf1f64 --- /dev/null +++ b/molecule/supervisor/goss/configs.yml.j2 @@ -0,0 +1,113 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[unix_http_server]" + - "file=/tmp/supervisor.sock" + - "chmod=0700" + - "chown=nobody:nogroup" + - "[supervisord]" + - "logfile=/var/log/supervisord.log" + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/supervisor/goss/default.yml.j2 b/molecule/supervisor/goss/default.yml.j2 new file mode 100644 index 000000000..4fb5a502b --- /dev/null +++ b/molecule/supervisor/goss/default.yml.j2 @@ -0,0 +1,16 @@ +--- + +package: + supervisor: + installed: true + +command: + dpkg -s supervisor: + exit-status: 0 + stdout: + - "Version:" + +service: + supervisor: + enabled: true + running: true diff --git a/molecule/supervisor/molecule.yml b/molecule/supervisor/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/supervisor/prepare.yml b/molecule/supervisor/prepare.yml new file mode 100644 index 000000000..1b7cd50d5 --- /dev/null +++ b/molecule/supervisor/prepare.yml @@ -0,0 +1,12 @@ +--- + +- hosts: + - debian.stretch + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - supervisor@backports diff --git a/molecule/symfony_cli/converge.yml b/molecule/symfony_cli/converge.yml new file mode 100644 index 000000000..6db0b7bb5 --- /dev/null +++ b/molecule/symfony_cli/converge.yml @@ -0,0 +1,48 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.symfony_cli + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Version # +########### + +- name: Version + tags: [version] + hosts: debian + vars: + tests_dir: /molecule/symfony_cli/version + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Fixed + import_role: + name: manala.roles.symfony_cli + tasks_from: install + vars: + manala_symfony_cli_bin: "{{ tests_dir }}/fixed" + manala_symfony_cli_version: 4.16.0 + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/version.yml.j2') }}" diff --git a/molecule/symfony_cli/goss/default.yml.j2 b/molecule/symfony_cli/goss/default.yml.j2 new file mode 100644 index 000000000..4ce633705 --- /dev/null +++ b/molecule/symfony_cli/goss/default.yml.j2 @@ -0,0 +1,15 @@ +--- + +file: + {{ manala_symfony_cli_bin }}: + exists: true + mode: "0755" + owner: root + group: root + filetype: file + +command: + {{ manala_symfony_cli_bin }} -V --no-ansi: + exit-status: 0 + stdout: + - Symfony CLI version diff --git a/molecule/symfony_cli/goss/version.yml.j2 b/molecule/symfony_cli/goss/version.yml.j2 new file mode 100644 index 000000000..4b870b15e --- /dev/null +++ b/molecule/symfony_cli/goss/version.yml.j2 @@ -0,0 +1,17 @@ +--- + +file: + # Fixed + {{ tests_dir }}/fixed: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + +command: + # Fixed + {{ tests_dir }}/fixed -V --no-ansi: + exit-status: 0 + stdout: + - Symfony CLI version v4.16 diff --git a/molecule/symfony_cli/molecule.yml b/molecule/symfony_cli/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/systemd/converge.yml b/molecule/systemd/converge.yml new file mode 100644 index 000000000..a79148953 --- /dev/null +++ b/molecule/systemd/converge.yml @@ -0,0 +1,181 @@ +--- + +#################### +# Tmpfiles Configs # +#################### + +- name: Tmpfiles Configs + tags: [tmpfiles_configs] + hosts: debian + vars: + tests_dir: /molecule/systemd/tmpfiles_configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.systemd + tasks_from: tmpfiles_configs + vars: + manala_systemd_tmpfiles_configs_exclusive: false + manala_systemd_tmpfiles_configs_dir: "{{ tests_dir }}/default" + manala_systemd_tmpfiles_configs_defaults: {} + manala_systemd_tmpfiles_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.systemd + tasks_from: tmpfiles_configs + vars: + manala_systemd_tmpfiles_configs_exclusive: false + manala_systemd_tmpfiles_configs_dir: "{{ tests_dir }}/defaults" + manala_systemd_tmpfiles_configs_defaults: + template: fixtures/template.j2 + manala_systemd_tmpfiles_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.systemd + tasks_from: tmpfiles_configs + vars: + manala_systemd_tmpfiles_configs_exclusive: true + manala_systemd_tmpfiles_configs_dir: "{{ tests_dir }}/exclusive" + manala_systemd_tmpfiles_configs_defaults: {} + manala_systemd_tmpfiles_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/tmpfiles_configs.yml.j2') }}" + +################## +# System Configs # +################## + +- name: System Configs + tags: [system_configs] + hosts: debian + vars: + tests_dir: /molecule/systemd/system_configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.systemd + tasks_from: system_configs + vars: + manala_systemd_system_configs_exclusive: false + manala_systemd_system_configs_dir: "{{ tests_dir }}/default" + manala_systemd_system_configs_defaults: {} + manala_systemd_system_configs: + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.systemd + tasks_from: system_configs + vars: + manala_systemd_system_configs_exclusive: false + manala_systemd_system_configs_dir: "{{ tests_dir }}/defaults" + manala_systemd_system_configs_defaults: + template: fixtures/template.j2 + manala_systemd_system_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.systemd + tasks_from: system_configs + vars: + manala_systemd_system_configs_exclusive: true + manala_systemd_system_configs_dir: "{{ tests_dir }}/exclusive" + manala_systemd_system_configs_defaults: {} + manala_systemd_system_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/system_configs.yml.j2') }}" diff --git a/molecule/systemd/fixtures/template.j2 b/molecule/systemd/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/systemd/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/systemd/fixtures/template_file.j2 b/molecule/systemd/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/systemd/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/systemd/goss/system_configs.yml.j2 b/molecule/systemd/goss/system_configs.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/systemd/goss/system_configs.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/systemd/goss/tmpfiles_configs.yml.j2 b/molecule/systemd/goss/tmpfiles_configs.yml.j2 new file mode 100644 index 000000000..ff0e5852f --- /dev/null +++ b/molecule/systemd/goss/tmpfiles_configs.yml.j2 @@ -0,0 +1,99 @@ +--- + +file: + + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/molecule/systemd/molecule.yml b/molecule/systemd/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/telegraf/converge.yml b/molecule/telegraf/converge.yml new file mode 100644 index 000000000..be82fd6fc --- /dev/null +++ b/molecule/telegraf/converge.yml @@ -0,0 +1,183 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.telegraf + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/telegraf/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.telegraf + vars: + manala_telegraf_config_file: "{{ tests_dir }}/dict" + manala_telegraf_config_template: ~ + manala_telegraf_config: + global_tags: + foo: bar + agent: + hostname: test.manala.dev + quiet: true + metric_batch_size: 1234 + outputs: + file: + - files: [/dev/null] + inputs: + cpu: + - {} + - name: Role - Content + import_role: + # Play role fully on first run, so that handlers don't breaks + name: manala.roles.telegraf + vars: + manala_telegraf_config_file: "{{ tests_dir }}/content" + manala_telegraf_config_template: ~ + manala_telegraf_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.telegraf + tasks_from: config + vars: + manala_telegraf_config_file: "{{ tests_dir }}/template" + manala_telegraf_config_template: fixtures/template.j2 + manala_telegraf_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" + +########### +# Configs # +########### + +- name: Configs + tags: [configs] + hosts: debian + vars: + tests_dir: /molecule/telegraf/configs + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item.0 }}" + state: "{{ item.1 }}" + loop: "{{ ['default', 'defaults', 'exclusive'] | product(['absent', 'directory']) }}" + - name: Touch existing files # noqa risky-file-permissions + file: + path: "{{ tests_dir }}/{{ item }}" + state: touch + loop: [ + default/state_absent_existing, default/state_ignore_existing, + exclusive/existing, exclusive/existing_present, exclusive/existing_ignore, + ] + - block: + - name: Role - Default + import_role: + name: manala.roles.telegraf + tasks_from: configs + vars: + manala_telegraf_configs_exclusive: false + manala_telegraf_configs_dir: "{{ tests_dir }}/default" + manala_telegraf_configs_defaults: {} + manala_telegraf_configs: + # Dict + - file: dict + config: + global_tags: + foo: bar + agent: + hostname: test.manala.dev + quiet: true + metric_batch_size: 1234 + outputs: + file: + - files: [/dev/null] + inputs: + cpu: + - {} + # Content + - file: content + config: | + Content + # Template + - file: template + template: fixtures/template.j2 + - template: fixtures/template_file.j2 + # Flatten + - + - file: flatten + # State + - file: state_present_implicit + - file: state_present + state: present + - file: state_absent + state: absent + - file: state_absent_existing + state: absent + - file: state_ignore + state: ignore + - file: state_ignore_existing + state: ignore + - name: Role - Defaults + import_role: + name: manala.roles.telegraf + tasks_from: configs + vars: + manala_telegraf_configs_exclusive: false + manala_telegraf_configs_dir: "{{ tests_dir }}/defaults" + manala_telegraf_configs_defaults: + template: fixtures/template.j2 + manala_telegraf_configs: + - file: template + - template: fixtures/template_file.j2 + - file: template_overwrite + template: fixtures/template_file.j2 + - name: Role - Exclusive + import_role: + name: manala.roles.telegraf + tasks_from: configs + vars: + manala_telegraf_configs_exclusive: true + manala_telegraf_configs_dir: "{{ tests_dir }}/exclusive" + manala_telegraf_configs_defaults: {} + manala_telegraf_configs: + - file: existing_present + - file: existing_ignore + state: ignore + - file: ignore + state: ignore + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/configs.yml.j2') }}" diff --git a/molecule/telegraf/fixtures/template.j2 b/molecule/telegraf/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/telegraf/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/telegraf/fixtures/template_file.j2 b/molecule/telegraf/fixtures/template_file.j2 new file mode 100644 index 000000000..af5d85858 --- /dev/null +++ b/molecule/telegraf/fixtures/template_file.j2 @@ -0,0 +1 @@ +Template file diff --git a/molecule/telegraf/goss/config.yml.j2 b/molecule/telegraf/goss/config.yml.j2 new file mode 100644 index 000000000..a915ecf37 --- /dev/null +++ b/molecule/telegraf/goss/config.yml.j2 @@ -0,0 +1,32 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[global_tags]" + - 'foo = "bar"' + - "[agent]" + - 'hostname = "test.manala.dev"' + - "quiet = true" + - "metric_batch_size = 1234" + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/molecule/telegraf/goss/configs.yml.j2 b/molecule/telegraf/goss/configs.yml.j2 new file mode 100644 index 000000000..e87537290 --- /dev/null +++ b/molecule/telegraf/goss/configs.yml.j2 @@ -0,0 +1,113 @@ +--- + +file: + + # Default - Dict + {{ tests_dir }}/default/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "[global_tags]" + - 'foo = "bar"' + - "[agent]" + - 'hostname = "test.manala.dev"' + - "quiet = true" + - "metric_batch_size = 1234" + # Default - Content + {{ tests_dir }}/default/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + # Default - Template + {{ tests_dir }}/default/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/default/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + # Default - Flatten + {{ tests_dir }}/default/flatten: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + # Default - State + {{ tests_dir }}/default/state_present_implicit: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/default/state_absent: + exists: false + {{ tests_dir }}/default/state_absent_existing: + exists: false + {{ tests_dir }}/default/state_ignore: + exists: false + {{ tests_dir }}/default/state_ignore_existing: + exists: true + filetype: file + + # Defaults + {{ tests_dir }}/defaults/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" + {{ tests_dir }}/defaults/template_file: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + {{ tests_dir }}/defaults/template_overwrite: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template file$/" + + # Exclusive + {{ tests_dir }}/exclusive/existing: + exists: false + {{ tests_dir }}/exclusive/existing_present: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + {{ tests_dir }}/exclusive/existing_ignore: + exists: false + {{ tests_dir }}/exclusive/ignore: + exists: false diff --git a/roles/telegraf/tests/0000_default.goss.yml b/molecule/telegraf/goss/default.yml.j2 similarity index 100% rename from roles/telegraf/tests/0000_default.goss.yml rename to molecule/telegraf/goss/default.yml.j2 diff --git a/molecule/telegraf/molecule.yml b/molecule/telegraf/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/telegraf/prepare.yml b/molecule/telegraf/prepare.yml new file mode 100644 index 000000000..c9325ea3c --- /dev/null +++ b/molecule/telegraf/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - telegraf@influxdata diff --git a/molecule/timezone/converge.yml b/molecule/timezone/converge.yml new file mode 100644 index 000000000..fc0ed7ccf --- /dev/null +++ b/molecule/timezone/converge.yml @@ -0,0 +1,21 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.timezone + vars: + manala_timezone_default: Africa/Bamako + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/timezone/tests/0100_default.goss.yml b/molecule/timezone/goss/default.yml.j2 similarity index 100% rename from roles/timezone/tests/0100_default.goss.yml rename to molecule/timezone/goss/default.yml.j2 diff --git a/molecule/timezone/molecule.yml b/molecule/timezone/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/vault_cli/converge.yml b/molecule/vault_cli/converge.yml new file mode 100644 index 000000000..b7a2575d1 --- /dev/null +++ b/molecule/vault_cli/converge.yml @@ -0,0 +1,48 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.vault_cli + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########### +# Version # +########### + +- name: Version + tags: [version] + hosts: debian + vars: + tests_dir: /molecule/vault_cli/version + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Fixed + import_role: + name: manala.roles.vault_cli + tasks_from: install + vars: + manala_vault_cli_bin: "{{ tests_dir }}/fixed" + manala_vault_cli_version: 1.4.3 + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/version.yml.j2') }}" diff --git a/molecule/vault_cli/goss/default.yml.j2 b/molecule/vault_cli/goss/default.yml.j2 new file mode 100644 index 000000000..2069465eb --- /dev/null +++ b/molecule/vault_cli/goss/default.yml.j2 @@ -0,0 +1,14 @@ +--- + +file: + {{ manala_vault_cli_bin }}: + exists: true + mode: "0755" + owner: root + filetype: file + +command: + {{ manala_vault_cli_bin }} --version: + exit-status: 0 + stdout: + - Vault v diff --git a/molecule/vault_cli/goss/version.yml.j2 b/molecule/vault_cli/goss/version.yml.j2 new file mode 100644 index 000000000..faa23dcc4 --- /dev/null +++ b/molecule/vault_cli/goss/version.yml.j2 @@ -0,0 +1,17 @@ +--- + +file: + # Fixed + {{ tests_dir }}/fixed: + exists: true + filetype: file + owner: root + group: root + mode: "0755" + +command: + # Fixed + {{ tests_dir }}/fixed --version: + exit-status: 0 + stdout: + - Vault v1.4.3 diff --git a/molecule/vault_cli/molecule.yml b/molecule/vault_cli/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/vault_cli/prepare.yml b/molecule/vault_cli/prepare.yml new file mode 100644 index 000000000..7b60958fe --- /dev/null +++ b/molecule/vault_cli/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Packages + apt: + name: [unzip] + install_recommends: false + update_cache: true + cache_valid_time: 3600 diff --git a/molecule/vim/converge.yml b/molecule/vim/converge.yml new file mode 100644 index 000000000..e9d227316 --- /dev/null +++ b/molecule/vim/converge.yml @@ -0,0 +1,68 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.vim + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" + +########## +# Config # +########## + +- name: Config + tags: [config] + hosts: debian + vars: + tests_dir: /molecule/vim/config + tasks: + - name: Clean tests dir # noqa risky-file-permissions + file: + path: "{{ tests_dir }}" + state: "{{ item }}" + loop: [absent, directory] + - block: + - name: Role - Dict + import_role: + name: manala.roles.vim + tasks_from: config + vars: + manala_vim_config_file: "{{ tests_dir }}/dict" + manala_vim_config_template: ~ + manala_vim_config: + encoding: utf8 + expandtab: true + - name: Role - Content + import_role: + name: manala.roles.vim + tasks_from: config + vars: + manala_vim_config_file: "{{ tests_dir }}/content" + manala_vim_config_template: ~ + manala_vim_config: | + Content + - name: Role - Template + import_role: + name: manala.roles.vim + tasks_from: config + vars: + manala_vim_config_file: "{{ tests_dir }}/template" + manala_vim_config_template: fixtures/template.j2 + manala_vim_config: ~ + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/config.yml.j2') }}" diff --git a/molecule/vim/fixtures/template.j2 b/molecule/vim/fixtures/template.j2 new file mode 100644 index 000000000..1cea569fe --- /dev/null +++ b/molecule/vim/fixtures/template.j2 @@ -0,0 +1 @@ +Template diff --git a/molecule/vim/goss/config.yml.j2 b/molecule/vim/goss/config.yml.j2 new file mode 100644 index 000000000..ff5b14e9d --- /dev/null +++ b/molecule/vim/goss/config.yml.j2 @@ -0,0 +1,28 @@ +--- + +file: + {{ tests_dir }}/dict: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - set encoding=utf8 + - set expandtab + {{ tests_dir }}/content: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Content$/" + {{ tests_dir }}/template: + exists: true + filetype: file + owner: root + group: root + mode: "0644" + contains: + - "/^Template$/" diff --git a/roles/vim/tests/0000_default.goss.yml b/molecule/vim/goss/default.yml.j2 similarity index 100% rename from roles/vim/tests/0000_default.goss.yml rename to molecule/vim/goss/default.yml.j2 diff --git a/molecule/vim/molecule.yml b/molecule/vim/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/yarn/converge.yml b/molecule/yarn/converge.yml new file mode 100644 index 000000000..c8a877752 --- /dev/null +++ b/molecule/yarn/converge.yml @@ -0,0 +1,19 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.yarn + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/yarn/tests/0100_install.goss.yml b/molecule/yarn/goss/default.yml.j2 similarity index 100% rename from roles/yarn/tests/0100_install.goss.yml rename to molecule/yarn/goss/default.yml.j2 diff --git a/molecule/yarn/molecule.yml b/molecule/yarn/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/molecule/yarn/prepare.yml b/molecule/yarn/prepare.yml new file mode 100644 index 000000000..5045571ac --- /dev/null +++ b/molecule/yarn/prepare.yml @@ -0,0 +1,11 @@ +--- + +- hosts: debian + tags: [always] + tasks: + - name: Apt + import_role: + name: manala.roles.apt + vars: + manala_apt_preferences: + - yarn@yarn diff --git a/molecule/zsh/converge.yml b/molecule/zsh/converge.yml new file mode 100644 index 000000000..c075e99f2 --- /dev/null +++ b/molecule/zsh/converge.yml @@ -0,0 +1,19 @@ +--- + +########### +# Default # +########### + +- name: Default + tags: [default] + hosts: debian + tasks: + - block: + - name: Role + import_role: + name: manala.roles.zsh + always: + - name: Goss + command: + cmd: goss --gossfile - validate + stdin: "{{ lookup('template', 'goss/default.yml.j2') }}" diff --git a/roles/zsh/tests/0100_install.goss.yml b/molecule/zsh/goss/default.yml.j2 similarity index 100% rename from roles/zsh/tests/0100_install.goss.yml rename to molecule/zsh/goss/default.yml.j2 diff --git a/molecule/zsh/molecule.yml b/molecule/zsh/molecule.yml new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/.gitignore b/plugins/.gitignore new file mode 100644 index 000000000..bee8a64b7 --- /dev/null +++ b/plugins/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/plugins/action/files_attributes.py b/plugins/action/files_attributes.py new file mode 100644 index 000000000..59f191833 --- /dev/null +++ b/plugins/action/files_attributes.py @@ -0,0 +1,252 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +from ansible.plugins.action import ActionBase + +import os + + +class FailedException(Exception): + def __init__(self, result): + self.result = result + + +class ActionModule(ActionBase): + + TRANSFERS_FILES = False + + def _run_module(self, name, args, task_args=None, task_vars=None): + task_args = task_args or [] + task_vars = task_vars or {} + + # Relevant task args + for key in task_args: + if key in self._task.args: + args[key] = self._task.args[key] + # Action + if name in ['template', 'copy']: + task = self._task.copy() + task.args = args + action = self._shared_loader_obj.action_loader.get( + name, + task=task, + connection=self._connection, + play_context=self._play_context, + loader=self._loader, + templar=self._templar, + shared_loader_obj=self._shared_loader_obj) + result = action.run(task_vars=task_vars) + else: + result = self._execute_module( + module_name=name, + module_args=args, + task_vars=task_vars) + if result.get('failed'): + raise FailedException(result) + return result + + def run(self, tmp=None, task_vars=None): + if task_vars is None: + task_vars = dict() + + result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect + + path = self._task.args.get('path') + state = self._task.args.get('state', 'file') + + result['changed'] = False + result['diff'] = [] + + try: + + # Absent + if (state == 'absent' and ( + 'template' in self._task.args + or 'content' in self._task.args + or 'copy' in self._task.args)): + return self._run_module( + 'file', + {'path': path, 'state': 'absent'}, + task_vars=task_vars) + + # Parents + if (self._task.args.get('parents') and ( + 'template' in self._task.args + or 'content' in self._task.args + or state == 'link' + or state == 'file')): + parents_result = self._run_module( + 'file', + {'path': os.path.dirname(path), 'state': 'directory'}, + task_args=['owner', 'group', 'mode'], + task_vars=task_vars) + result['changed'] |= parents_result['changed'] + result['diff'] += [parents_result['diff']] + + ############ + # Template # + ############ + + if 'template' in self._task.args: + + # Template + template_result = self._run_module( + 'template', + {'dest': path, 'src': self._task.args.get('template')}, + task_args=['force', 'owner', 'group', 'mode'], + task_vars=task_vars) + result['changed'] |= template_result['changed'] + result['diff'] += template_result['diff'] + + ########### + # Content # + ########### + + elif 'content' in self._task.args: + + # Content + content_result = self._run_module( + 'copy', + {'dest': path, 'content': self._task.args.get('content')}, + task_args=['force', 'owner', 'group', 'mode'], + task_vars=task_vars) + result['changed'] |= content_result['changed'] + result['diff'] += content_result['diff'] + + ######## + # Copy # + ######## + + elif 'copy' in self._task.args: + + result = self._run_module( + 'copy', + {'dest': path, 'src': self._task.args.get('copy')}, + task_args=['force', 'owner', 'group', 'mode'], + task_vars=task_vars) + + ####### + # Url # + ####### + + elif 'url' in self._task.args: + + # Url + url_result = self._run_module( + 'get_url', + {'dest': path, 'url': self._task.args.get('url')}, + task_args=['validate_certs', 'force', 'owner', 'group', 'mode'], + task_vars=task_vars) + result['changed'] |= url_result['changed'] + + # Unarchive + if self._task.args.get('unarchive', False) and not self._play_context.check_mode: + unarchive_result = self._run_module( + 'unarchive', + {'src': path, 'dest': os.path.dirname(path), 'remote_src': True}, + task_args=['creates'], + task_vars=task_vars) + + ######## + # Link # + ######## + + elif state == 'link': + + # Force + if self._task.args.get('force'): + link_stat = self._execute_remote_stat(path, task_vars, follow=False) + + if link_stat['exists'] and not link_stat['islnk']: + absent_result = self._run_module( + 'file', + {'path': path, 'state': 'absent'}, + task_vars=task_vars) + result['changed'] |= absent_result['changed'] + result['diff'] += [absent_result['diff']] + + # Link + link_result = self._run_module( + 'file', + {'path': path, 'src': self._task.args.get('src'), 'state': 'link'}, + task_args=['owner', 'group'], + task_vars=task_vars) + result['changed'] |= link_result['changed'] + result['diff'] += link_result['diff'] + + ############# + # Directory # + ############# + + elif state == 'directory': + + # Force + if self._task.args.get('force'): + link_stat = self._execute_remote_stat(path, task_vars, follow=True) + + if link_stat['exists'] and not link_stat['isdir']: + absent_result = self._run_module( + 'file', + {'path': path, 'state': 'absent'}, + task_vars=task_vars) + result['changed'] |= absent_result['changed'] + result['diff'] += [absent_result['diff']] + + # Directory + directory_result = self._run_module( + 'file', + {'path': path, 'state': 'directory'}, + task_args=['owner', 'group', 'mode'], + task_vars=task_vars) + result['changed'] |= directory_result['changed'] + result['diff'] += directory_result['diff'] + + ######## + # File # + ######## + + elif state == 'file': + + # Force + if self._task.args.get('force'): + link_stat = self._execute_remote_stat(path, task_vars, follow=True) + + if link_stat['exists'] and not link_stat['isreg']: + absent_result = self._run_module( + 'file', + {'path': path, 'state': 'absent'}, + task_vars=task_vars) + result['changed'] |= absent_result['changed'] + result['diff'] += [absent_result['diff']] + + # Create + create_result = self._run_module( + 'copy', + {'dest': path, 'content': '', 'force': False}, + task_args=['owner', 'group', 'mode'], + task_vars=task_vars) + result['changed'] |= create_result['changed'] + + # File + file_result = self._run_module( + 'file', + {'path': path, 'state': 'file'}, + task_args=['owner', 'group', 'mode'], + task_vars=task_vars) + result['changed'] |= file_result['changed'] + result['diff'] += file_result['diff'] + + # Other... + else: + + result = self._run_module( + 'file', + {'path': path}, + task_args=['state', 'follow', 'recurse', 'src', 'force', 'owner', 'group', 'mode'], + task_vars=task_vars) + + return result + + except FailedException as failed: + return failed.result diff --git a/plugins/callback/deploy_log.py b/plugins/callback/deploy_log.py new file mode 100644 index 000000000..242e089b3 --- /dev/null +++ b/plugins/callback/deploy_log.py @@ -0,0 +1,49 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: deploy_log + author: Manala (@manala) + short_description: print stdout/stderr + description: + - Print stdout/stderr +''' + +from ansible.plugins.callback import CallbackBase + + +class CallbackModule(CallbackBase): + CALLBACK_VERSION = 2.0 + CALLBACK_TYPE = 'notification' + CALLBACK_NAME = 'manala_deploy_log' + CALLBACK_NEEDS_WHITELIST = False + + def v2_runner_item_on_failed(self, result): + if ('module_stdout' in result._result) and result._result.get('module_stdout'): + print('module_stdout:') + print(result._result.get('module_stdout')) + if ('module_stderr' in result._result) and result._result.get('module_stderr'): + print('module_stderr:') + print(result._result.get('module_stderr')) + if ('stdout' in result._result) and result._result.get('stdout'): + print('stdout:') + print(result._result.get('stdout')) + if ('stderr' in result._result) and result._result.get('stderr'): + print('stderr:') + print(result._result.get('stderr')) + + def v2_runner_on_failed(self, result, ignore_errors=False): + if ('stdout' in result._result) and result._result.get('stdout'): + print('stdout:') + print(result._result.get('stdout')) + if ('stderr' in result._result) and result._result.get('stderr'): + print('stderr:') + print(result._result.get('stderr')) + + def v2_runner_on_ok(self, result): + if ('stdout' in result._result) and result._result.get('stdout'): + print('stdout:') + print(result._result.get('stdout')) + if ('stderr' in result._result) and result._result.get('stderr'): + print('stderr:') + print(result._result.get('stderr')) diff --git a/plugins/filter/apt_architecture.py b/plugins/filter/apt_architecture.py new file mode 100644 index 000000000..9eaed06ed --- /dev/null +++ b/plugins/filter/apt_architecture.py @@ -0,0 +1,27 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError + +ARCHITECTURE_MAP = { + 'x86_64': 'amd64', + 'aarch64': 'arm64', + 'armv7l': 'armhf', +} + + +def architecture(architecture): + if architecture not in ARCHITECTURE_MAP: + raise AnsibleFilterError('unsupported "%s" architecture' % architecture) + return ARCHITECTURE_MAP[architecture] + + +class FilterModule(object): + ''' Manala apt jinja2 filters ''' + + def filters(self): + filters = { + 'apt_architecture': architecture, + } + + return filters diff --git a/plugins/filter/backup_manager_config.py b/plugins/filter/backup_manager_config.py new file mode 100644 index 000000000..e698a09d7 --- /dev/null +++ b/plugins/filter/backup_manager_config.py @@ -0,0 +1,77 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types +from ansible.plugins.filter.core import flatten + +from numbers import Number + + +def config(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('backup_manager_config expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result.lstrip() + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('backup_manager_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('backup_manager_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('backup_manager_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('backup_manager_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is None: + result = 'export %s="none"' % key + elif value is True: + result = 'export %s="true"' % key + elif value is False: + result = 'export %s="false"' % key + elif isinstance(value, (string_types, Number)): + result = 'export %s="%s"' % (key, value) + elif isinstance(value, list): + value = flatten(value) + if value and all(isinstance(v, dict) for v in value): + result = '' + for index, value in enumerate(value): + for k, v in iteritems(value): + result += '%s_%s[%d]="%s"\n' % (key, k, index, v) + result = result.rstrip() + else: + result = 'export %s="%s"' % (key, ' '.join(value)) + else: + raise AnsibleFilterError('backup_manager_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = '#%s' % result + + return result + + +class FilterModule(object): + ''' Manala backup manager jinja2 filters ''' + + def filters(self): + filters = { + 'backup_manager_config': config, + 'backup_manager_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/filter/bind_zone.py b/plugins/filter/bind_zone.py new file mode 100644 index 000000000..61b354da5 --- /dev/null +++ b/plugins/filter/bind_zone.py @@ -0,0 +1,17 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +def zone_file(value): + return 'db.' + value.replace('.in-addr.arpa', '') + + +class FilterModule(object): + ''' Manala bind jinja2 filters ''' + + def filters(self): + filters = { + 'bind_zone_file': zone_file, + } + + return filters diff --git a/plugins/filter/environment.py b/plugins/filter/environment.py new file mode 100644 index 000000000..8689dd81a --- /dev/null +++ b/plugins/filter/environment.py @@ -0,0 +1,64 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types + +from numbers import Number + + +def environment(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('environment expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = environment_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result.lstrip() + + +def environment_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('environment_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('environment_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('environment_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('environment_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is None: + result = '' + elif isinstance(value, string_types): + result = '%s="%s"' % (key, value) + elif isinstance(value, Number): + result = '%s=%s' % (key, value) + else: + raise AnsibleFilterError('environment_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = '#' + result.replace('\n', '\n#') + + return result + + +class FilterModule(object): + ''' Manala environment jinja2 filters ''' + + def filters(self): + filters = { + 'environment': environment, + 'environment_parameter': environment_parameter, + } + + return filters diff --git a/plugins/filter/git_config.py b/plugins/filter/git_config.py new file mode 100644 index 000000000..bb4ab89bf --- /dev/null +++ b/plugins/filter/git_config.py @@ -0,0 +1,81 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types + +from numbers import Number + + +def config(sections, exclude=None): + exclude = exclude or [] + if not isinstance(sections, dict): + raise AnsibleFilterError('git_config expects a dict but was given a %s' % type(sections)) + [sections.pop(key, None) for key in exclude] + result = '' + for section, parameters in sorted(iteritems(sections)): + result += '[%s]%s\n\n' % ( + section, + config_section(parameters) + ) + return result.rstrip() + + +def config_section(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('git_config_section expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n %s' % parameter + return result + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('git_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('git_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('git_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('git_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is None: + result = '' + elif value is True: + result = '%s = true' % key + elif value is False: + result = '%s = false' % key + elif isinstance(value, (string_types, Number)): + result = '%s = %s' % (key, value) + else: + raise AnsibleFilterError('git_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = ';' + result.replace('\n', '\n;') + + return result + + +class FilterModule(object): + ''' Manala git config jinja2 filters ''' + + def filters(self): + filters = { + 'git_config': config, + 'git_config_section': config_section, + 'git_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/filter/gomplate_architecture.py b/plugins/filter/gomplate_architecture.py new file mode 100644 index 000000000..cf479c5d6 --- /dev/null +++ b/plugins/filter/gomplate_architecture.py @@ -0,0 +1,26 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError + +ARCHITECTURE_MAP = { + 'x86_64': 'amd64', + 'aarch64': 'arm64', +} + + +def architecture(architecture): + if architecture not in ARCHITECTURE_MAP: + raise AnsibleFilterError('unsupported "%s" architecture' % architecture) + return ARCHITECTURE_MAP[architecture] + + +class FilterModule(object): + ''' Manala gomplate jinja2 filters ''' + + def filters(self): + filters = { + 'gomplate_architecture': architecture, + } + + return filters diff --git a/plugins/filter/json.py b/plugins/filter/json.py new file mode 100644 index 000000000..e8539bad7 --- /dev/null +++ b/plugins/filter/json.py @@ -0,0 +1,26 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types +from ansible.plugins.filter.core import to_nice_json + + +def json(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('json expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = to_nice_json(parameters) + return result + + +class FilterModule(object): + ''' Manala json jinja2 filters ''' + + def filters(self): + filters = { + 'json': json, + } + + return filters diff --git a/plugins/filter/logrotate_config.py b/plugins/filter/logrotate_config.py new file mode 100644 index 000000000..152a2c896 --- /dev/null +++ b/plugins/filter/logrotate_config.py @@ -0,0 +1,79 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types + +from numbers import Number + + +def config(sections, exclude=None): + exclude = exclude or [] + if not isinstance(sections, dict): + raise AnsibleFilterError('logrotate_config expects a dict but was given a %s' % type(sections)) + [sections.pop(key, None) for key in exclude] + result = '' + for section, parameters in sorted(iteritems(sections)): + result += '%s {%s\n}\n' % ( + section, + config_section(parameters) + ) + return result.rstrip() + + +def config_section(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('logrotate_config_section expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n %s' % parameter + return result + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('logrotate_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('logrotate_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('logrotate_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('logrotate_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is True: + result = '%s' % key + elif value is False: + result = '' + elif isinstance(value, (string_types, Number)): + result = '%s %s' % (key, value) + else: + raise AnsibleFilterError('logrotate_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = '#%s' % result + + return result + + +class FilterModule(object): + ''' Manala logrotate jinja2 filters ''' + + def filters(self): + filters = { + 'logrotate_config': config, + 'logrotate_config_section': config_section, + 'logrotate_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/filter/mysql_config.py b/plugins/filter/mysql_config.py new file mode 100644 index 000000000..cee0d6d55 --- /dev/null +++ b/plugins/filter/mysql_config.py @@ -0,0 +1,79 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types + +from numbers import Number + + +def config(sections, exclude=None): + exclude = exclude or [] + if not isinstance(sections, dict): + raise AnsibleFilterError('mysql_config expects a dict but was given a %s' % type(sections)) + [sections.pop(key, None) for key in exclude] + result = '' + for section, parameters in sorted(iteritems(sections)): + result += '[%s]%s\n\n' % ( + section, + config_section(parameters) + ) + return result.rstrip() + + +def config_section(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('mysql_config_section expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('mysql_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('mysql_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('mysql_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('mysql_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is True: + result = '%s = ON' % key + elif value is False: + result = '%s = OFF' % key + elif isinstance(value, (string_types, Number)): + result = '%s = %s' % (key, value) + else: + raise AnsibleFilterError('mysql_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = '#%s' % result + + return result + + +class FilterModule(object): + ''' Manala mysql config jinja2 filters ''' + + def filters(self): + filters = { + 'mysql_config': config, + 'mysql_config_section': config_section, + 'mysql_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/filter/nginx_config.py b/plugins/filter/nginx_config.py new file mode 100644 index 000000000..df1bab30b --- /dev/null +++ b/plugins/filter/nginx_config.py @@ -0,0 +1,70 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types +from ansible.plugins.filter.core import flatten + +from numbers import Number + + +def config(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('nginx_config expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result.lstrip() + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('nginx_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('nginx_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('nginx_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('nginx_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is True: + result = '%s on;' % key + elif value is False: + result = '%s off;' % key + elif isinstance(value, list): + value = flatten(value) + result = '\n'.join( + config_parameter({key: v}, key) for v in value + ) + elif isinstance(value, (string_types, Number)): + result = '%s %s;' % (key, value) + else: + raise AnsibleFilterError('nginx_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = '#' + result.replace('\n', '\n#') + + return result + + +class FilterModule(object): + ''' Manala nginx config jinja2 filters ''' + + def filters(self): + filters = { + 'nginx_config': config, + 'nginx_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/filter/ngrok_architecture.py b/plugins/filter/ngrok_architecture.py new file mode 100644 index 000000000..ddbc93df1 --- /dev/null +++ b/plugins/filter/ngrok_architecture.py @@ -0,0 +1,26 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError + +ARCHITECTURE_MAP = { + 'x86_64': 'amd64', + 'aarch64': 'arm64', +} + + +def architecture(architecture): + if architecture not in ARCHITECTURE_MAP: + raise AnsibleFilterError('unsupported "%s" architecture' % architecture) + return ARCHITECTURE_MAP[architecture] + + +class FilterModule(object): + ''' Manala ngrok jinja2 filters ''' + + def filters(self): + filters = { + 'ngrok_architecture': architecture, + } + + return filters diff --git a/plugins/filter/php_blackfire_config.py b/plugins/filter/php_blackfire_config.py new file mode 100644 index 000000000..dccedde3a --- /dev/null +++ b/plugins/filter/php_blackfire_config.py @@ -0,0 +1,75 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types + +from numbers import Number + + +def config(sections, exclude=None): + exclude = exclude or [] + if not isinstance(sections, dict): + raise AnsibleFilterError('php_blackfire_config expects a dict but was given a %s' % type(sections)) + [sections.pop(key, None) for key in exclude] + result = '' + for section, parameters in sorted(iteritems(sections)): + result += '[%s]%s\n\n' % ( + section, + config_section(parameters) + ) + return result.rstrip() + + +def config_section(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('php_blackfire_config_section expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('php_blackfire_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('php_blackfire_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('php_blackfire_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('php_blackfire_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if isinstance(value, (string_types, Number)): + result = '%s=%s' % (key, value) + else: + raise AnsibleFilterError('php_blackfire_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = '; ' + result.replace('\n', '\n; ') + + return result + + +class FilterModule(object): + ''' Manala php blackfire config jinja2 filters ''' + + def filters(self): + filters = { + 'php_blackfire_config': config, + 'php_blackfire_config_section': config_section, + 'php_blackfire_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/filter/php_config.py b/plugins/filter/php_config.py new file mode 100644 index 000000000..7909da388 --- /dev/null +++ b/plugins/filter/php_config.py @@ -0,0 +1,64 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types + +from numbers import Number + + +def config(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('php_config expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result.lstrip() + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('php_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('php_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('php_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('php_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is True: + result = '%s = On' % key + elif value is False: + result = '%s = Off' % key + elif isinstance(value, (string_types, Number)): + result = '%s = %s' % (key, value) + else: + raise AnsibleFilterError('php_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = ';' + result.replace('\n', '\n;') + + return result + + +class FilterModule(object): + ''' Manala php config jinja2 filters ''' + + def filters(self): + filters = { + 'php_config': config, + 'php_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/filter/php_fpm_pools.py b/plugins/filter/php_fpm_pools.py new file mode 100644 index 000000000..cfe806470 --- /dev/null +++ b/plugins/filter/php_fpm_pools.py @@ -0,0 +1,95 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types + +from numbers import Number + + +def pools(sections, exclude=None): + exclude = exclude or [] + if not isinstance(sections, dict): + raise AnsibleFilterError('php_fpm_pools expects a dict but was given a %s' % type(sections)) + [sections.pop(key, None) for key in exclude] + result = '' + for section, parameters in sorted(iteritems(sections)): + result += '[%s]%s\n\n' % ( + section, + pools_section(parameters) + ) + return result.rstrip() + + +def pools_section(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('php_fpm_pools_section expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = pools_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result + + +def pools_parameter(parameters, key, required=False, comment=False, quote=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('php_fpm_pools_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('php_fpm_pools_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('php_fpm_pools_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('php_fpm_pools_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is True: + if quote: + raise AnsibleFilterError('php_fpm_pools_parameter unquotable boolean value') + result = '%s = yes' % key + elif value is False: + if quote: + raise AnsibleFilterError('php_fpm_pools_parameter unquotable boolean value') + result = '%s = no' % key + elif isinstance(value, (string_types, Number)): + if value == '': + result = '%s =' % key + else: + if quote: + result = '%s = "%s"' % (key, value) + else: + result = '%s = %s' % (key, value) + elif isinstance(value, dict): + result = '' + for k, v in sorted(iteritems(value)): + k = '%s[%s]' % (key, k) + result += pools_parameter({k: v}, k, quote=quote) + '\n' + result = result.rsplit('\n', 1)[0] + else: + raise AnsibleFilterError('php_fpm_pools_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = ';' + result.replace('\n', '\n;') + + return result + + +class FilterModule(object): + ''' Manala php fpm pools jinja2 filters ''' + + def filters(self): + filters = { + 'php_fpm_pools': pools, + 'php_fpm_pools_section': pools_section, + 'php_fpm_pools_parameter': pools_parameter, + } + + return filters diff --git a/plugins/filter/proftpd_config.py b/plugins/filter/proftpd_config.py new file mode 100644 index 000000000..bf8d72537 --- /dev/null +++ b/plugins/filter/proftpd_config.py @@ -0,0 +1,66 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types + +from numbers import Number + + +def config(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('proftpd_config expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result.lstrip() + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('proftpd_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('proftpd_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('proftpd_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('proftpd_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is None: + result = '' + elif value is True: + result = '%s on' % key + elif value is False: + result = '%s off' % key + elif isinstance(value, (string_types, Number)): + result = '%s %s' % (key, value) + else: + raise AnsibleFilterError('proftpd_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = '#%s' % result + + return result + + +class FilterModule(object): + ''' Manala proftpd jinja2 filters ''' + + def filters(self): + filters = { + 'proftpd_config': config, + 'proftpd_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/filter/redis_config.py b/plugins/filter/redis_config.py new file mode 100644 index 000000000..a18ced483 --- /dev/null +++ b/plugins/filter/redis_config.py @@ -0,0 +1,70 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types +from ansible.plugins.filter.core import flatten + +from numbers import Number + + +def config(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('redis_config expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result.lstrip() + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('redis_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('redis_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('redis_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('redis_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is True: + result = '%s yes' % key + elif value is False: + result = '%s no' % key + elif isinstance(value, list): + value = flatten(value) + result = '\n'.join( + config_parameter({key: v}, key) for v in value + ) + elif isinstance(value, (string_types, Number)): + result = '%s %s' % (key, value) + else: + raise AnsibleFilterError('redis_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = '# ' + result.replace('\n', '\n# ') + + return result + + +class FilterModule(object): + ''' Manala redis jinja2 filters ''' + + def filters(self): + filters = { + 'redis_config': config, + 'redis_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/filter/rsyslog_config.py b/plugins/filter/rsyslog_config.py new file mode 100644 index 000000000..54a254ba2 --- /dev/null +++ b/plugins/filter/rsyslog_config.py @@ -0,0 +1,60 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types + +from numbers import Number + + +def config(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('rsyslog_config expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result.lstrip() + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('rsyslog_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('rsyslog_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('rsyslog_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('rsyslog_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if isinstance(value, (string_types, Number)): + result = '%s %s' % (key, value) + else: + raise AnsibleFilterError('rsyslog_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = '#%s' % result + + return result + + +class FilterModule(object): + ''' Manala rsyslog jinja2 filters ''' + + def filters(self): + filters = { + 'rsyslog_config': config, + 'rsyslog_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/filter/ssh_config.py b/plugins/filter/ssh_config.py new file mode 100644 index 000000000..4d134d6a7 --- /dev/null +++ b/plugins/filter/ssh_config.py @@ -0,0 +1,75 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types + +from numbers import Number + + +def config(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('ssh_config expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result.lstrip() + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('ssh_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('ssh_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('ssh_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('ssh_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is None: + result = '%s none' % key + elif value is True: + result = '%s yes' % key + elif value is False: + result = '%s no' % key + elif isinstance(value, (string_types, Number)): + result = '%s %s' % (key, value) + elif isinstance(value, dict): + result = '%s\n' % key + for k, v in sorted(iteritems(value)): + result += ' ' + config_parameter({k: v}, k) + '\n' + result = result.rsplit('\n', 1)[0] + elif isinstance(value, list): + result = '\n'.join( + config_parameter({key: v}, key) for v in value + ) + else: + raise AnsibleFilterError('ssh_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = '#' + result.replace('\n', '\n#') + + return result + + +class FilterModule(object): + ''' Manala ssh config jinja2 filters ''' + + def filters(self): + filters = { + 'ssh_config': config, + 'ssh_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/filter/staten.py b/plugins/filter/staten.py new file mode 100644 index 000000000..5a4b4d92e --- /dev/null +++ b/plugins/filter/staten.py @@ -0,0 +1,72 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils._text import to_text +from ansible.module_utils.common._collections_compat import Iterable + + +def staten_ignore(values): + if not isinstance(values, Iterable): + raise AnsibleFilterError('Expected an iterable but was a %s' % type(values)) + + results = [] + + for value in values: + if isinstance(value, dict) and value.get('state') == 'ignore': + continue + + results.append(value) + + return results + + +def staten(values, **kwargs): + if not isinstance(values, Iterable): + raise AnsibleFilterError('Expected an iterable but was a %s' % type(values)) + + results = [] + + want = kwargs.pop('want', None) + + if want and want not in ['present', 'absent']: + raise AnsibleFilterError('Expected a want of "present" or "absent" but was "%s"' % to_text(want)) + + values = staten_ignore(values) + + for value in values: + # Short syntax + if not isinstance(value, dict): + item = value + + # In short syntax, 'present' state is implicit + if want and want != 'present': + continue + else: + # Default state + item = { + 'state': 'present' + } + item.update(value) + + if item['state'] not in ['present', 'absent']: + raise AnsibleFilterError('Expected a state of "present" or "absent" but was "%s"' % to_text(item['state'])) + + if want and want != item['state']: + continue + + results.append(item) + + return results + + +class FilterModule(object): + ''' Manala staten filter ''' + + def filters(self): + filters = { + 'staten_ignore': staten_ignore, + 'staten': staten, + } + + return filters diff --git a/plugins/filter/supervisor_config.py b/plugins/filter/supervisor_config.py new file mode 100644 index 000000000..6bff2a1be --- /dev/null +++ b/plugins/filter/supervisor_config.py @@ -0,0 +1,88 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types +from ansible.plugins.filter.core import flatten + +from numbers import Number + + +def config(sections, exclude=None): + exclude = exclude or [] + if not isinstance(sections, dict): + raise AnsibleFilterError('supervisor_config expects a dict but was given a %s' % type(sections)) + [sections.pop(key, None) for key in exclude] + result = '' + for section, parameters in sorted(iteritems(sections)): + result += '[%s]%s\n\n' % ( + section, + config_section(parameters) + ) + return result.rstrip() + + +def config_section(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('supervisor_config_section expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('supervisor_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('supervisor_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('supervisor_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('supervisor_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is True: + result = '%s=true' % key + elif value is False: + result = '%s=false' % key + elif isinstance(value, (string_types, Number)): + result = '%s=%s' % (key, value) + elif isinstance(value, dict): + result = '%s=' % key + for k, v in sorted(iteritems(value)): + result += '%s="%s",' % (k, v) + result = result.rsplit(',', 1)[0] + elif isinstance(value, list): + value = flatten(value) + result = '%s=%s' % (key, ','.join(value)) + else: + raise AnsibleFilterError('supervisor_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = ';' + result.replace('\n', '\n;') + + return result + + +class FilterModule(object): + ''' Manala supervisor config jinja2 filters ''' + + def filters(self): + filters = { + 'supervisor_config': config, + 'supervisor_config_section': config_section, + 'supervisor_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/filter/symfony_cli_architecture.py b/plugins/filter/symfony_cli_architecture.py new file mode 100644 index 000000000..60e14c9bb --- /dev/null +++ b/plugins/filter/symfony_cli_architecture.py @@ -0,0 +1,26 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError + +ARCHITECTURE_MAP = { + 'x86_64': 'amd64', + 'aarch64': 'arm64', +} + + +def architecture(architecture): + if architecture not in ARCHITECTURE_MAP: + raise AnsibleFilterError('unsupported "%s" architecture' % architecture) + return ARCHITECTURE_MAP[architecture] + + +class FilterModule(object): + ''' Manala symfony cli jinja2 filters ''' + + def filters(self): + filters = { + 'symfony_cli_architecture': architecture, + } + + return filters diff --git a/plugins/filter/toml.py b/plugins/filter/toml.py new file mode 100644 index 000000000..f9db0947e --- /dev/null +++ b/plugins/filter/toml.py @@ -0,0 +1,300 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import string_types + +import re + +""" +Config Encoder Filters +More information: https://github.com/jtyr/ansible-config_encoder_filters +""" + + +def _is_num(data): + """Verify if data is either int or float. + Could be replaced by: + from numbers import Number as number + isinstance(data, number) + but that requires Python v2.6+. + """ + + return isinstance(data, int) or isinstance(data, float) + + +def _escape(data, quote='"', format=None): + """Escape special characters in a string.""" + + if format == 'xml': + return ( + str(data). + replace('&', '&'). + replace('<', '<'). + replace('>', '>')) + elif format == 'control': + return ( + str(data). + replace('\b', '\\b'). + replace('\f', '\\f'). + replace('\n', '\\n'). + replace('\r', '\\r'). + replace('\t', '\\t')) + elif quote is not None and len(quote): + return str(data).replace('\\', '\\\\').replace(quote, "\\%s" % quote) + else: + return data + + +def _str_is_int(data): + """Verify if data is integer.""" + + return re.match(r"^[-+]?(0|[1-9][0-9]*)$", str(data)) + + +def _str_is_float(data): + """Verify if data is float.""" + + return re.match( + r"^[-+]?(0|[1-9][0-9]*)(\.[0-9]*)?(e[-+]?[0-9]+)?$", + str(data), flags=re.IGNORECASE) + + +def _str_is_num(data): + """Verify if data is either integer or float.""" + + return _str_is_int(data) or _str_is_float(data) + + +def _str_is_bool(data): + """Verify if data is boolean.""" + + return re.match(r"^(true|false)$", str(data), flags=re.IGNORECASE) + + +def encode_toml( + data, convert_bools=False, convert_nums=False, first=True, quote='"', + table_name="", table_type=None): + """Convert Python data structure to TOML format.""" + + # Return value + rv = "" + + if isinstance(data, dict): + # It's a dict + + tn = table_name + + # First process all keys with elementar value (num/str/bool/array) + for k, v in sorted(data.items()): + + if not (isinstance(v, dict) or isinstance(v, list)): + if tn: + if not first: + rv += "\n" + + if table_type == 'table': + rv += "[%s]\n" % tn + else: + rv += "[[%s]]\n" % tn + + rv += "%s = %s\n" % ( + k, + encode_toml( + v, + convert_bools=convert_bools, + convert_nums=convert_nums, + first=first, + quote=quote)) + + first = False + tn = '' + elif isinstance(v, list) and (not v or not isinstance(v[0], dict)): + if tn: + if not first: + rv += "\n" + + if table_type == 'table': + rv += "[%s]\n" % tn + else: + rv += "[[%s]]\n" % tn + + rv += "%s = %s\n" % ( + k, + encode_toml( + v, + convert_bools=convert_bools, + convert_nums=convert_nums, + first=first, + quote=quote)) + + first = False + tn = '' + + if not data and table_type is not None: + if not first: + rv += "\n" + + if table_type == 'table': + rv += "[%s]\n" % tn + else: + rv += "[[%s]]\n" % tn + + # Then process tables and arrays of tables + for k, v in sorted(data.items()): + tn = table_name + + if isinstance(v, dict): + # Table + tk = k + + if '.' in k: + tk = "%s%s%s" % (quote, _escape(k, quote), quote) + + if tn: + tn += ".%s" % tk + else: + tn += "%s" % tk + + rv += encode_toml( + v, + convert_bools=convert_bools, + convert_nums=convert_nums, + first=first, + quote=quote, + table_name=tn, + table_type='table') + + first = False + elif isinstance(v, list) and (not v or isinstance(v[0], dict)): + # Array of tables + tk = k + + if '.' in k: + tk = "%s%s%s" % (quote, _escape(k, quote), quote) + + if tn: + tn += ".%s" % tk + else: + tn += "%s" % tk + + for t in v: + rv += encode_toml( + t, + convert_bools=convert_bools, + convert_nums=convert_nums, + first=first, + quote=quote, + table_name=tn, + table_type='table_array') + + first = False + + elif isinstance(data, list): + + # Check if all values are elementar (num/str/bool/array) + def is_elem(a): + all_elementar = True + + for lv in a: + if ( + isinstance(lv, dict) or ( + isinstance(lv, list) and + not is_elem(lv))): + all_elementar = False + break + + return all_elementar + + if is_elem(data): + v_len = len(data) + + array = '' + + for i, lv in enumerate(data): + array += "%s" % encode_toml( + lv, + convert_bools=convert_bools, + convert_nums=convert_nums, + first=first, + quote=quote) + + if i + 1 < v_len: + array += ', ' + + rv += "[%s]" % (array) + + elif ( + _is_num(data) or + isinstance(data, bool) or + (convert_nums and _str_is_num(data)) or + (convert_bools and _str_is_bool(data))): + # It's number or boolean + + rv += str(data).lower() + + elif isinstance(data, string_types): + # It's a string + + rv += "%s%s%s" % (quote, _escape(data, quote), quote) + + return rv + + +def toml(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('toml expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key) for key in exclude] + return encode_toml(parameters).rstrip() + + +def toml_section(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('toml_section expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key) for key in exclude] + result = '' + for key in sorted(parameters): + result += '\n %s' % toml_parameter(parameters, key) + return result + + +def toml_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('toml_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('toml_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('toml_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('toml_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + result = encode_toml({ + key: value + }).strip() + + if key not in parameters and comment: + result = '# ' + result.replace('\n', '\n# ') + + return result + + +class FilterModule(object): + ''' Manala toml jinja2 filters ''' + + def filters(self): + filters = { + 'toml': toml, + 'toml_section': toml_section, + 'toml_parameter': toml_parameter, + } + + return filters diff --git a/plugins/filter/users_groups.py b/plugins/filter/users_groups.py new file mode 100644 index 000000000..d09013ce9 --- /dev/null +++ b/plugins/filter/users_groups.py @@ -0,0 +1,37 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.common._collections_compat import Iterable + + +def users_groups(users, groups=None): + if not isinstance(users, Iterable): + raise AnsibleFilterError('Expected an iterable but was a %s' % type(users)) + groups = groups or [] + if not isinstance(groups, Iterable): + raise AnsibleFilterError('Expected a groups iterable but was a %s' % type(groups)) + + results = [] + + for user in users: + for group in groups: + if 'skipped' in group and group['skipped']: + continue + if group['item']['user'] == user['user']: + user['group'] = group['stdout'] + break + results.append(user) + + return results + + +class FilterModule(object): + ''' Manala users groups filter ''' + + def filters(self): + filters = { + 'users_groups': users_groups, + } + + return filters diff --git a/plugins/filter/vault_cli_architecture.py b/plugins/filter/vault_cli_architecture.py new file mode 100644 index 000000000..51ef352bd --- /dev/null +++ b/plugins/filter/vault_cli_architecture.py @@ -0,0 +1,26 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError + +ARCHITECTURE_MAP = { + 'x86_64': 'amd64', + 'aarch64': 'arm64', +} + + +def architecture(architecture): + if architecture not in ARCHITECTURE_MAP: + raise AnsibleFilterError('unsupported "%s" architecture' % architecture) + return ARCHITECTURE_MAP[architecture] + + +class FilterModule(object): + ''' Manala vault cli jinja2 filters ''' + + def filters(self): + filters = { + 'vault_cli_architecture': architecture, + } + + return filters diff --git a/plugins/filter/vim_config.py b/plugins/filter/vim_config.py new file mode 100644 index 000000000..9e553f07d --- /dev/null +++ b/plugins/filter/vim_config.py @@ -0,0 +1,64 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types + +from numbers import Number + + +def config(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('vim_config expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result.lstrip() + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('vim_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('vim_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('vim_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('vim_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is None: + result = 'set %s' % key + elif value is True: + result = 'set %s' % key + elif isinstance(value, (string_types, Number)): + result = 'set %s=%s' % (key, value) + else: + raise AnsibleFilterError('vim_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = ';' + result.replace('\n', '\n;') + + return result + + +class FilterModule(object): + ''' Manala vim config jinja2 filters ''' + + def filters(self): + filters = { + 'vim_config': config, + 'vim_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/filter/yaml.py b/plugins/filter/yaml.py new file mode 100644 index 000000000..b66bdc871 --- /dev/null +++ b/plugins/filter/yaml.py @@ -0,0 +1,70 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types +from ansible.plugins.filter.core import to_nice_yaml + + +def yaml(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('yaml expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = yaml_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result.lstrip() + + +def yaml_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('yaml_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('yaml_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('yaml_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('yaml_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + result = to_nice_yaml({key: value},).rstrip() + + if key not in parameters and comment: + result = '#' + result.replace('\n', '\n#') + + return result + + +def yaml_flatten(parameters, parent='', separator='.'): + if not isinstance(parameters, dict): + raise AnsibleFilterError('yaml_flatten expects a dict but was given a %s' % type(parameters)) + items = [] + for key, value in parameters.items(): + key = (parent + separator + key) if parent else key + if isinstance(value, dict): + items.extend(yaml_flatten(value, key, separator=separator).items()) + else: + items.append((key, value)) + return dict(items) + + +class FilterModule(object): + ''' Manala yaml jinja2 filters ''' + + def filters(self): + filters = { + 'yaml': yaml, + 'yaml_parameter': yaml_parameter, + 'yaml_flatten': yaml_flatten, + } + + return filters diff --git a/plugins/filter/zsh_config.py b/plugins/filter/zsh_config.py new file mode 100644 index 000000000..3dd4a27a5 --- /dev/null +++ b/plugins/filter/zsh_config.py @@ -0,0 +1,72 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.errors import AnsibleFilterError +from ansible.module_utils.six import iteritems, string_types +from ansible.plugins.filter.core import flatten + +from numbers import Number + + +def config(parameters, exclude=None): + exclude = exclude or [] + if not isinstance(parameters, dict): + raise AnsibleFilterError('zsh_config expects a dict but was given a %s' % type(parameters)) + [parameters.pop(key, None) for key in exclude] + result = '' + for key in sorted(parameters): + parameter = config_parameter(parameters, key) + if parameter: + result += '\n%s' % parameter + return result.lstrip() + + +def config_parameter(parameters, key, required=False, comment=False, **kwargs): + if not isinstance(parameters, dict): + raise AnsibleFilterError('zsh_config_parameter parameters expects a dict but was given a %s' % type(parameters)) + if not isinstance(key, string_types): + raise AnsibleFilterError('zsh_config_parameter key expects a string but was given a %s' % type(key)) + + if key in parameters: + value = parameters.get(key) + else: + if required: + raise AnsibleFilterError('zsh_config_parameter requires a value for key %s' % key) + if isinstance(comment, string_types): + return comment + if 'default' not in kwargs: + raise AnsibleFilterError('zsh_config_parameter missing a default value for key %s' % key) + value = kwargs.get('default') + + if value is None: + result = '%s=""' % key + elif value is True: + result = '%s="true"' % key + elif value is False: + result = '%s="false"' % key + elif isinstance(value, string_types): + result = '%s="%s"' % (key, value) + elif isinstance(value, Number): + result = '%s=%s' % (key, value) + elif isinstance(value, list): + value = flatten(value) + result = '%s=(%s)' % (key, ' '.join(value)) + else: + raise AnsibleFilterError('zsh_config_parameter value of an unknown type %s' % type(value)) + + if key not in parameters and comment: + result = '# ' + result.replace('\n', '\n# ') + + return result + + +class FilterModule(object): + ''' Manala zsh config jinja2 filters ''' + + def filters(self): + filters = { + 'zsh_config': config, + 'zsh_config_parameter': config_parameter, + } + + return filters diff --git a/plugins/lookup/accounts_users_authorized_keys.py b/plugins/lookup/accounts_users_authorized_keys.py new file mode 100644 index 000000000..45c529795 --- /dev/null +++ b/plugins/lookup/accounts_users_authorized_keys.py @@ -0,0 +1,88 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: accounts_users_authorized_keys + author: Manala (@manala) + short_description: returns a curated users authorized keys list + description: + - Takes a users authorized keys list and returns it curated. +''' + +from ansible.plugins.lookup import LookupBase +from ansible.errors import AnsibleError +from ansible.module_utils.six import string_types + +import os.path + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + variables = variables or {} + + results = [] + + users = self._flatten(terms) + + itemDefault = {} + + for user in users: + + # Must be a dict + if not isinstance(user, dict): + continue + + # Check index key + if 'user' not in user: + raise AnsibleError('Missing "user" key') + + # Mandatory field + if 'authorized_keys' not in user: + continue + + items = [] + + item = itemDefault.copy() + item.update(user) + item.update({ + 'authorized_keys': '\n'.join(user['authorized_keys']), + }) + + # File + if 'authorized_keys_file' in user: + # Empty + if not user.get('authorized_keys_file'): + item.pop("authorized_keys_file") + # Omit + elif user.get('authorized_keys_file') == variables.get('omit'): + item.pop("authorized_keys_file") + # Path + elif isinstance(user.get('authorized_keys_file'), string_types): + # Absolute + if user.get('authorized_keys_file').startswith('/'): + item.update({ + 'authorized_keys_file': user.get('authorized_keys_file') + }) + # Relative + else: + item.update({ + 'authorized_keys_file': os.path.expanduser('~' + user.get('user') + '/.ssh/' + user.get('authorized_keys_file')) + }) + + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['user'] == item['user']: + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + return results diff --git a/plugins/lookup/ansible_galaxy_roles.py b/plugins/lookup/ansible_galaxy_roles.py new file mode 100644 index 000000000..2efe4d037 --- /dev/null +++ b/plugins/lookup/ansible_galaxy_roles.py @@ -0,0 +1,57 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: ansible_galaxy_roles + author: Manala (@manala) + short_description: returns a curated roles list + description: + - Takes a roles list and returns it curated. +''' + +from ansible.plugins.lookup import LookupBase +from ansible.module_utils.six import string_types +from ansible.errors import AnsibleError + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + roles = self._flatten(terms) + + for role in roles: + + items = [] + + # Short syntax + if isinstance(role, string_types): + items.append({ + 'src': role + }) + else: + + # Must be a dict + if not isinstance(role, dict): + raise AnsibleError('Expected a dict but was a %s' % type(role)) + + # Check index key + if 'src' not in role: + raise AnsibleError('Missing "src" key') + + items.append(role) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['src'] == item['src']: + results[i] = item + itemFound = True + break + if not itemFound: + results.append(item) + + return results diff --git a/plugins/lookup/apt_holds.py b/plugins/lookup/apt_holds.py new file mode 100644 index 000000000..2cef995fa --- /dev/null +++ b/plugins/lookup/apt_holds.py @@ -0,0 +1,83 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: apt_holds + author: Manala (@manala) + short_description: returns a curated holds list + description: + - Takes a holds list and returns it curated. +''' + +from ansible.plugins.lookup import LookupBase +from ansible.errors import AnsibleError +from ansible.module_utils.six import string_types +from ansible.module_utils._text import to_text + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + holds = self._flatten(terms[0]) + exclusives = self._flatten(terms[1]) + + itemDefault = { + 'state': 'present' + } + + # Unhold exclusives + for hold in exclusives: + item = itemDefault.copy() + item.update({ + 'package': hold, + 'state': 'absent' + }) + results.append(item) + + for hold in holds: + + items = [] + + item = itemDefault.copy() + + # Short syntax + if isinstance(hold, string_types): + item.update({ + 'package': hold, + 'state': 'present' + }) + else: + # Must be a dict + if not isinstance(hold, dict): + raise AnsibleError('Expected a dict but was a %s' % type(hold)) + + # Check package key + if 'package' not in hold: + raise AnsibleError('Missing "package" key') + + item.update(hold) + + if item['state'] not in ['present', 'absent', 'ignore']: + raise AnsibleError('Expected a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) + + if item['state'] == 'ignore': + continue + + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['package'] == item['package']: + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + return results diff --git a/plugins/lookup/apt_keys.py b/plugins/lookup/apt_keys.py new file mode 100644 index 000000000..3fdb16dac --- /dev/null +++ b/plugins/lookup/apt_keys.py @@ -0,0 +1,70 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: apt_keys + author: Manala (@manala) + short_description: returns a curated keys list + description: + - Takes a keys list and returns it curated. +''' + +from ansible.plugins.lookup import LookupBase +from ansible.errors import AnsibleError +from ansible.module_utils.six import string_types + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + keys = self._flatten(terms[0]) + keysPatterns = terms[1] + repositories = terms[2] + + itemDefault = {} + + # Handle repositories defined as reversed preferences + for repository in repositories[::-1]: + if 'key' in repository: + keys.insert(0, repository.get('key')) + + for key in keys: + + items = [] + + item = itemDefault.copy() + + # Short syntax + if isinstance(key, string_types): + item.update( + keysPatterns.get(key) + ) + else: + # Must be a dict + if not isinstance(key, dict): + raise AnsibleError('Expected a dict but was a %s' % type(key)) + + # Check id key + if 'id' not in key: + raise AnsibleError('Missing "id" key') + + item.update(key) + + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['id'] == item['id']: + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + return results diff --git a/plugins/lookup/apt_packages.py b/plugins/lookup/apt_packages.py new file mode 100644 index 000000000..0079cf302 --- /dev/null +++ b/plugins/lookup/apt_packages.py @@ -0,0 +1,97 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: apt_packages + author: Manala (@manala) + short_description: returns a curated packages list + description: + - Takes a packages list and returns it curated. +''' + +from ansible.plugins.lookup import LookupBase +from ansible.errors import AnsibleError +from ansible.module_utils.six import string_types +from ansible.module_utils._text import to_text + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + packages = self._flatten(terms[0]) + + groups = [] + + itemDefault = { + 'state': 'present', + 'deb': False + } + + for package in packages: + + items = [] + + item = itemDefault.copy() + + # Short syntax + if isinstance(package, string_types): + item.update({ + 'package': package + }) + else: + + # Must be a dict + if not isinstance(package, dict): + raise AnsibleError('Expected a dict but was a %s' % type(package)) + + # Check index key + if 'package' not in package: + raise AnsibleError('Missing "package" key') + + item.update(package) + + if item['state'] not in ['present', 'absent', 'ignore']: + raise AnsibleError('Expected a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) + + if item['state'] == 'ignore': + continue + + # Is a .deb ? + if item.get('package').endswith('.deb'): + item.update({ + 'deb': True + }) + + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, group in enumerate(groups): + if group['package'] == item['package']: + groups[i] = item + itemFound = True + break + + if not itemFound: + groups.append(item) + + # Groups + for group in groups: + # Deb packages could only be installed one by one + if group['deb']: + results.append(group) + else: + # If package share the previous one state, group them + if results and not results[-1]['deb'] and group['state'] == results[-1]['state']: + results[-1]['package'].append(group['package']) + else: + group.update({ + 'package': [group['package']] + }) + results.append(group) + + return results diff --git a/plugins/lookup/apt_preferences.py b/plugins/lookup/apt_preferences.py new file mode 100644 index 000000000..c407c63bc --- /dev/null +++ b/plugins/lookup/apt_preferences.py @@ -0,0 +1,150 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: apt_preferences + author: Manala (@manala) + short_description: returns a curated preferences list + description: + - Takes a preferences list and returns it curated and optionally state filtered. + options: + wantstate: + description: filter list items by state +''' + +from ansible.plugins.lookup import LookupBase +from ansible.errors import AnsibleError +from ansible.module_utils.six import string_types +from ansible.module_utils._text import to_text + +import os.path +import re + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + wantstate = kwargs.pop('wantstate', None) + + if wantstate and wantstate not in ['present', 'absent']: + raise AnsibleError('Expected a wanstate of "present" or "absent" but was "%s"' % to_text(wantstate)) + + preferences = self._flatten(terms[0]) + preferencesPatterns = terms[1] + repositoriesPatterns = terms[2] + exclusives = self._flatten(terms[3]) + dir = terms[4] + template = terms[5] + + itemDefault = { + 'state': 'present', + 'template': template + } + + # Mark exclusive preferences as absent + for preference in exclusives: + item = itemDefault.copy() + item.update({ + 'file': preference['path'], + 'state': 'absent' + }) + results.append(item) + + for preference in preferences: + + items = [] + + item = itemDefault.copy() + + # Short syntax + if isinstance(preference, string_types): + item.update({ + 'preference': preference + }) + else: + # Must be a dict + if not isinstance(preference, dict): + raise AnsibleError('Expected a dict but was a %s' % type(preference)) + + item.update(preference) + + if item['state'] not in ['present', 'absent', 'ignore']: + raise AnsibleError('Expected a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) + + if item['state'] == 'ignore': + continue + + if 'preference' in item: + pattern = item['preference'] + preferencePattern = pattern.split('@')[0] + if 'file' not in item: + item.update({ + 'file': preferencePattern + .split(':')[0] + .replace('.', '_') + }) + if 'package' not in item: + item.update({ + 'package': preferencesPatterns.get( + preferencePattern.split(':')[0], + (preferencePattern.split(':')[0]) if len(pattern.split('@')) > 1 else ('*') + ) + }) + if 'pin' not in item: + repositoryPattern = ( + (pattern.split('@')[1]) if len(pattern.split('@')) > 1 else (pattern) + ).split(':')[0] + if repositoryPattern not in repositoriesPatterns: + raise AnsibleError('unable to find "%s" repository pattern' % repositoryPattern) + item.update({ + 'pin': repositoriesPatterns + .get(repositoryPattern) + .get( + 'pin', + 'origin ' + re.sub( + 'deb (\\[.+\\] )?https?:\\/\\/([^\\/ ]+)[\\/ ].*$', + '\\2', + repositoriesPatterns + .get(repositoryPattern) + .get('source') + ) + ), + 'repository': repositoryPattern, + }) + if 'priority' not in item: + item.update({ + 'priority': int( + (pattern.split(':')[1]) if len(pattern.split(':')) > 1 else (1000) + ) + }) + + # Check index key + if 'file' not in item: + raise AnsibleError('Missing "file" key') + + item.update({ + 'file': os.path.join(dir, item['file']) + }) + + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['file'] == item['file']: + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + # Filter by state + if wantstate: + results = [result for result in results if result.get('state') == wantstate] + + return results diff --git a/plugins/lookup/apt_repositories.py b/plugins/lookup/apt_repositories.py new file mode 100644 index 000000000..25bb5dc6a --- /dev/null +++ b/plugins/lookup/apt_repositories.py @@ -0,0 +1,135 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: apt_repositories + author: Manala (@manala) + short_description: returns a curated repositories list + description: + - Takes a repositories list and returns it curated and optionally state filtered. + options: + wantstate: + description: filter list items by state +''' + +from ansible.plugins.lookup import LookupBase +from ansible.errors import AnsibleError +from ansible.module_utils.six import string_types +from ansible.module_utils._text import to_text + +import os.path +import re + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + wantstate = kwargs.pop('wantstate', None) + + if wantstate and wantstate not in ['present', 'absent']: + raise AnsibleError('Expected a wanstate of "present" or "absent" but was "%s"' % to_text(wantstate)) + + repositories = self._flatten(terms[0]) + repositoriesPatterns = terms[1] + preferences = terms[2] + exclusives = self._flatten(terms[3]) + dir = '/etc/apt/sources.list.d' + + itemDefault = { + 'state': 'present' + } + + # Mark exclusive repositories as absent + for repository in exclusives: + item = itemDefault.copy() + item.update({ + 'file': repository['path'], + 'state': 'absent' + }) + results.append(item) + + # Handle repositories defined as reversed preferences + for preference in preferences[::-1]: + if 'repository' in preference: + repositories.insert(0, preference['repository']) + + for repository in repositories: + + items = [] + + item = itemDefault.copy() + + # Short syntax + if isinstance(repository, string_types): + item.update({ + 'repository': repository + }) + else: + # Must be a dict + if not isinstance(repository, dict): + raise AnsibleError('Expected a dict but was a %s' % type(repository)) + + item.update(repository) + + if item['state'] not in ['present', 'absent', 'ignore']: + raise AnsibleError('Expected a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) + + if item['state'] == 'ignore': + continue + + if 'repository' in item: + item.update( + repositoriesPatterns.get(item['repository']) + ) + + # Check index key + if 'source' not in item: + raise AnsibleError('Missing "source" key') + + # Force file if not present + if 'file' not in item: + item.update({ + 'file': os.path.join( + dir, + re.sub( + '^deb (\\[.+\\] )?https?:\\/\\/([^ ]+)[ ].*$', + '\\2', + item['source'] + ) + .strip('/ ') + .replace('.', '_') + .replace('/', '_') + .replace('-', '_') + + '.list' + ) + }) + else: + item.update({ + 'file': os.path.join( + dir, + item['file'] + ) + }) + + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if ('source' in result and result['source'] == item['source']) or (result['file'] == item['file']): + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + # Filter by state + if wantstate: + results = [result for result in results if result.get('state') == wantstate] + + return results diff --git a/plugins/lookup/deploy_tasks.py b/plugins/lookup/deploy_tasks.py new file mode 100644 index 000000000..e8f673d2e --- /dev/null +++ b/plugins/lookup/deploy_tasks.py @@ -0,0 +1,81 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: deploy_tasks + author: Manala (@manala) + short_description: returns a curated tasks list + description: + - Takes a tasks list and returns it curated. +''' + +from ansible.plugins.lookup import LookupBase +from ansible.module_utils.six import string_types +from ansible.errors import AnsibleError + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + variables = variables or {} + + results = [] + + tasks = self._flatten(terms) + + itemDefault = { + 'options': None, + 'when': True, + 'dir': + ( + variables['deploy_helper'].get('new_release_path') + ) if 'deploy_helper' in variables else ( + variables.get('manala_deploy_dir', '') + '/' + variables.get('manala_deploy_current_dir', '') + ), + 'shared_dir': + ( + variables['deploy_helper'].get('shared_path') + ) if 'deploy_helper' in variables else ( + variables.get('manala_deploy_dir', '') + '/' + variables.get('manala_deploy_shared_dir', '') + ) + } + + for task in tasks: + + items = [] + + # Short syntax + if isinstance(task, string_types): + item = itemDefault.copy() + item.update({ + 'task': task + }) + items.append(item) + else: + + # Must be a dict + if not isinstance(task, dict): + raise AnsibleError('Expected a dict but was a %s' % type(task)) + + # Guess task (first one not in blacklist) + item = None + for taskKey, taskValue in task.items(): + if taskKey not in ['when']: + item = itemDefault.copy() + item.update({ + 'task': taskKey, + 'options': taskValue + }) + break + if item: + item.update({ + 'when': task.get('when') if 'when' in task else True + }) + items.append(item) + + # Merge + for item in items: + results.append(item) + + return results diff --git a/plugins/lookup/deploy_writable_dirs.py b/plugins/lookup/deploy_writable_dirs.py new file mode 100644 index 000000000..f427adf60 --- /dev/null +++ b/plugins/lookup/deploy_writable_dirs.py @@ -0,0 +1,62 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: deploy_writable_dirs + author: Manala (@manala) + short_description: returns a curated writable dirs list + description: + - Takes a writable dirs list and returns it curated. +''' + +from ansible.plugins.lookup import LookupBase +from ansible.module_utils.six import string_types +from ansible.errors import AnsibleError + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + dirs = self._flatten(terms[0]) + default = terms[1] + + for dir in dirs: + + items = [] + + # Short syntax + if isinstance(dir, string_types): + item = default.copy() + item.update({ + 'dir': dir + }) + items.append(item) + else: + + # Must be a dict + if not isinstance(dir, dict): + raise AnsibleError('Expected a dict but was a %s' % type(dir)) + + # Check index key + if 'dir' not in dir: + raise AnsibleError('Missing "dir" key') + + item = default.copy() + item.update(dir) + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['dir'] == item['dir']: + results[i] = item + itemFound = True + break + if not itemFound: + results.append(item) + + return results diff --git a/plugins/lookup/docker_applications.py b/plugins/lookup/docker_applications.py new file mode 100644 index 000000000..bcd226133 --- /dev/null +++ b/plugins/lookup/docker_applications.py @@ -0,0 +1,87 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: docker_applications + author: Manala (@manala) + short_description: returns a curated applications list + description: + - Takes a repositories list and returns it curated. +''' + +from ansible.plugins.lookup import LookupBase +from ansible.module_utils.six import string_types +from ansible.errors import AnsibleError + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + applications = self._flatten(terms[0]) + patterns = terms[1] + + itemDefault = { + 'tag': None, + 'rm': None, + 'interactive': None, + 'tty': None, + 'command': None, + 'volumes': {}, + 'environment': {}, + 'workdir': None + } + + for application in applications: + + items = [] + + # Short syntax + if isinstance(application, string_types): + item = itemDefault.copy() + + item.update({ + 'image': application.split(':')[0], + 'application': ((application.split('/')[1]).split(':')[0]) if len(application.split('/')) > 1 else (application.split(':')[0]) + }) + + # Pattern + if application.split(':')[0] in patterns: + item.update(patterns.get(application.split(':')[0])) + + # Tag + if len(application.split(':')) > 1: + item.update({ + 'tag': application.split(':')[1] + }) + else: + + # Must be a dict + if not isinstance(application, dict): + raise AnsibleError('Expected a dict but was a %s' % type(application)) + + # Check index key + if 'application' not in application: + raise AnsibleError('Missing "application" key') + + item = itemDefault.copy() + + item.update(application) + + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['application'] == item['application']: + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + return results diff --git a/plugins/lookup/environment_files.py b/plugins/lookup/environment_files.py new file mode 100644 index 000000000..d7a63ba9f --- /dev/null +++ b/plugins/lookup/environment_files.py @@ -0,0 +1,66 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: environment_files + author: Manala (@manala) + short_description: returns a curated files list + description: + - Takes a files list and returns it curated. +''' + +from ansible.plugins.lookup import LookupBase +from ansible.module_utils.six import string_types +from ansible.errors import AnsibleError + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + files = self._flatten(terms[0]) + patterns = terms[1] + + itemDefault = { + 'export': False + } + + for file in files: + + items = [] + + # Short syntax + if isinstance(file, string_types): + if file not in patterns: + raise AnsibleError('"%s" is not a valid pattern' % (file)) + + item = itemDefault.copy() + item.update(patterns.get(file)) + items.append(item) + else: + # Must be a dict + if not isinstance(file, dict): + raise AnsibleError('Expected a dict but was a %s' % type(file)) + + # Check index key + if 'file' not in file: + raise AnsibleError('Missing "file" key') + + item = itemDefault.copy() + item.update(file) + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['file'] == item['file']: + results[i] = item + itemFound = True + break + if not itemFound: + results.append(item) + + return results diff --git a/plugins/lookup/files_attributes.py b/plugins/lookup/files_attributes.py new file mode 100644 index 000000000..eece055d9 --- /dev/null +++ b/plugins/lookup/files_attributes.py @@ -0,0 +1,89 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: files_attributes + author: Manala (@manala) + short_description: returns a curated attributes list + description: + - Takes a attributes list and returns it curated. +''' + +from ansible.plugins.lookup import LookupBase +from ansible.errors import AnsibleError + +import re + + +class LookupModule(LookupBase): + + def _default(self, defaults, path): + result = {} + for default in defaults: + if ('path' not in default) or (re.search(default['path'], path)): + result.update(default) + return result + + def run(self, terms, variables=None, **kwargs): + + results = [] + + attributes = self._flatten(terms[0]) + defaults = self._flatten(terms[1]) + + itemDefault = {} + + for attribute in attributes: + + items = [] + + # Must be a dict + if not isinstance(attribute, dict): + raise AnsibleError('Expected a dict but was a %s' % type(attribute)) + + # Check path key + if 'path' not in attribute: + raise AnsibleError('Missing "path" key') + + state = attribute.get('state') + + # Ignore + if state == 'ignore': + continue + + # Composite link + if state in ['link_directory', 'link_file']: + if 'src' not in attribute: + raise AnsibleError('Missing "src" key') + + # Composite + item = itemDefault.copy() + item.update(self._default(defaults, attribute['src'])) + item.update(attribute) + item.update({ + 'path': item.pop('src'), + 'state': state.split('_')[1] + }) + items.append(item) + + # Link + attribute['state'] = 'link' + + item = itemDefault.copy() + item.update(self._default(defaults, attribute['path'])) + item.update(attribute) + items.append(item) + + # Merge by path key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['path'] == item['path']: + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + return results diff --git a/plugins/lookup/locales_codes.py b/plugins/lookup/locales_codes.py new file mode 100644 index 000000000..bb5274926 --- /dev/null +++ b/plugins/lookup/locales_codes.py @@ -0,0 +1,120 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: locales_codes + author: Manala (@manala) + short_description: returns a curated codes list + description: + - Takes a repositories list and returns it curated and optionally state or denormalized filtered. + options: + wantstatecurrent: + description: filter list items by state current + wantcodedenormalized: + description: filter list items by code denormalized +''' + +from ansible.plugins.lookup import LookupBase +from ansible.module_utils.six import string_types +from ansible.errors import AnsibleError + +# As seen on native locale_gen module +LOCALE_NORMALIZATION = { + ".utf8": ".UTF-8", + ".eucjp": ".EUC-JP", + ".iso885915": ".ISO-8859-15", + ".cp1251": ".CP1251", + ".koi8r": ".KOI8-R", + ".armscii8": ".ARMSCII-8", + ".euckr": ".EUC-KR", + ".gbk": ".GBK", + ".gb18030": ".GB18030", + ".euctw": ".EUC-TW", +} + + +class LookupModule(LookupBase): + + # As seen on native locale_gen module + def normalize(self, name): + """locale -a might return the encoding in either lower or upper case. + Passing through this function makes them uniform for comparisons.""" + for s, r in LOCALE_NORMALIZATION.items(): + name = name.replace(s, r) + return name + + def denormalize(self, name): + """locale -a might return the encoding in either lower or upper case. + Passing through this function makes them uniform for comparisons.""" + for s, r in LOCALE_NORMALIZATION.items(): + name = name.replace(r, s) + return name + + def run(self, terms, variables=None, **kwargs): + + results = [] + + wantstatecurrent = kwargs.pop('wantstatecurrent', False) + wantcodedenormalized = kwargs.pop('wantcodedenormalized', False) + + codes = self._flatten(terms[0]) + codesPresents = self._flatten(terms[1]) + + itemDefault = { + 'state': 'present' + } + + for code in codes: + + items = [] + + # Short syntax + if isinstance(code, string_types): + item = itemDefault.copy() + item.update({ + 'code': code + }) + else: + + # Must be a dict + if not isinstance(code, dict): + raise AnsibleError('Expected a dict but was a %s' % type(code)) + + # Check index key + if 'code' not in code: + raise AnsibleError('Missing "code" key') + + item = itemDefault.copy() + item.update(code) + + item.update({ + 'code': self.normalize(item['code']) + }) + + if wantcodedenormalized: + codeDenormalized = self.denormalize(item['code']) + if codeDenormalized != item['code']: + item.update({ + 'code_denormalized': self.denormalize(item['code']) + }) + + if wantstatecurrent: + item.update({ + 'state_current': 'present' if any(item['code'] == self.normalize(code) for code in codesPresents) else 'absent' + }) + + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['code'] == item['code']: + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + return results diff --git a/plugins/lookup/npm_packages.py b/plugins/lookup/npm_packages.py new file mode 100644 index 000000000..1499ce929 --- /dev/null +++ b/plugins/lookup/npm_packages.py @@ -0,0 +1,61 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: npm_packages + author: Manala (@manala) + short_description: returns a curated packages list + description: + - Takes a packages list and returns it curated. +''' + + +from ansible.plugins.lookup import LookupBase +from ansible.module_utils.six import string_types +from ansible.errors import AnsibleError + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + packages = self._flatten(terms) + + itemDefault = {} + + for package in packages: + + items = [] + + item = itemDefault.copy() + + # Short syntax + if isinstance(package, string_types): + item.update({ + 'package': package + }) + else: + + # Check index key + if 'package' not in package: + raise AnsibleError('Missing "package" key') + + item.update(package) + + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['package'] == item['package']: + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + return results diff --git a/plugins/lookup/php_applications.py b/plugins/lookup/php_applications.py new file mode 100644 index 000000000..9d6702c6c --- /dev/null +++ b/plugins/lookup/php_applications.py @@ -0,0 +1,110 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: php_applications + author: Manala (@manala) + short_description: returns a curated applications list + description: + - Takes an applications list and returns it curated and optionally state filtered. + options: + wantstate: + description: filter list items by state +''' + + +from ansible.plugins.lookup import LookupBase +from ansible.errors import AnsibleError +from ansible.module_utils.six import string_types +from ansible.module_utils._text import to_text + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + wantstate = kwargs.pop('wantstate', None) + + if wantstate and wantstate not in ['present']: + raise AnsibleError('Expected a wanstate of "present" but was "%s"' % to_text(wantstate)) + + applications = self._flatten(terms[0]) + patterns = terms[1] + + itemDefault = { + 'state': 'present', + 'version': None, + 'source': None, + 'source_version': None + } + + for application in applications: + + items = [] + + # Short syntax + if isinstance(application, string_types): + item = itemDefault.copy() + + # Pattern + if application.split('@')[0] not in patterns: + raise AnsibleError('Unknown "%s" pattern' % application.split('@')[0]) + + item.update(patterns.get(application.split('@')[0])) + + item.update({ + 'application': application.split('@')[0], + 'version': application.split('@')[1] if (len(application.split('@')) > 1) else None + }) + + else: + + # Must be a dict + if not isinstance(application, dict): + raise AnsibleError('Expected a dict but was a %s' % type(application)) + + # Check index key + if 'application' not in application: + raise AnsibleError('Missing "application" key') + + item = itemDefault.copy() + + # Pattern + if application['application'] in patterns: + item.update(patterns.get(application['application'])) + + item.update(application) + + # Source version + if item.get('source_version') and item.get('version'): + item.update({ + 'source': item.get('source_version').format(version=item.get('version')) + }) + + # No source + if not item.get('source'): + raise AnsibleError('No source') + + if item['state'] not in ['present', 'ignore']: + raise AnsibleError('Expected a state of "present" or "ignore" but was "%s"' % to_text(item['state'])) + + if item['state'] == 'ignore': + continue + + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['application'] == item['application']: + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + return results diff --git a/plugins/lookup/php_extensions.py b/plugins/lookup/php_extensions.py new file mode 100644 index 000000000..e65a6d9d8 --- /dev/null +++ b/plugins/lookup/php_extensions.py @@ -0,0 +1,113 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: php_extensions + author: Manala (@manala) + short_description: returns a curated extensions list + description: + - Takes an extensions list and returns it curated and optionally state filtered. + options: + wantstate: + description: filter list items by enabled + wantenabled: + description: filter list items by state + wantmap: + description: format result list as a map +''' + + +from ansible.plugins.lookup import LookupBase +from ansible.module_utils.six import string_types +from ansible.errors import AnsibleError +from ansible.module_utils._text import to_text + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + wantstate = kwargs.pop('wantstate', None) + + if wantstate and wantstate not in ['present', 'absent']: + raise AnsibleError('Expected a wanstate of "present" or "absent" but was "%s"' % to_text(wantstate)) + + wantenabled = kwargs.pop('wantenabled', None) + wantmap = kwargs.pop('wantmap', False) + + extensions = self._flatten(terms[0]) + extensionsAvailable = terms[1] + + sapisAvailable = terms[2] + + itemDefault = { + 'state': 'present', + 'enabled': None + } + + for extension in extensions: + + items = [] + + # Short syntax + if isinstance(extension, string_types): + item = itemDefault.copy() + item.update({ + 'extension': extension + }) + else: + + # Must be a dict + if not isinstance(extension, dict): + raise AnsibleError('Expected a dict but was a %s' % type(extension)) + + # Check index key + if 'extension' not in extension: + raise AnsibleError('Missing "extension" key') + + item = itemDefault.copy() + item.update(extension) + + # Extension known as a sapi ? + if item['extension'] in sapisAvailable: + raise AnsibleError('Extension "%s" is known as a sapi' % item['extension']) + + # Already embedded extension ? + if item['extension'] in extensionsAvailable: + continue + + if item['state'] not in ['present', 'absent', 'ignore']: + raise AnsibleError('Expected a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) + + if item['state'] == 'ignore': + continue + + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['extension'] == item['extension']: + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + # Filter by state + if wantstate is not None: + results = [result for result in results if result.get('state') == wantstate] + + # Filter by enabled + if wantenabled is not None: + results = [result for result in results if result.get('enabled') == wantenabled] + + # Map + if wantmap: + results = [result.get('extension') for result in results] + + return results diff --git a/plugins/lookup/php_packages.py b/plugins/lookup/php_packages.py new file mode 100644 index 000000000..92e801904 --- /dev/null +++ b/plugins/lookup/php_packages.py @@ -0,0 +1,37 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: php_packages + author: Manala (@manala) + short_description: returns a curated packages list + description: + - Takes an packages list and returns it curated. +''' + + +from ansible.plugins.lookup import LookupBase + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + packages = self._flatten(terms[0]) + version = terms[1] + + for package in packages: + + items = [] + + # Extensions + items.append('php%s-%s' % (version, package)) + + # Merge + for item in items: + if item not in results: + results.append(item) + + return results diff --git a/plugins/lookup/php_packages_exclusive.py b/plugins/lookup/php_packages_exclusive.py new file mode 100644 index 000000000..41effdac1 --- /dev/null +++ b/plugins/lookup/php_packages_exclusive.py @@ -0,0 +1,71 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: php_packages_exclusive + author: Manala (@manala) + short_description: returns a curated absent packages list + description: + - Takes some packages list and returns a curated absent packages list. +''' + + +from ansible.plugins.lookup import LookupBase + +import re + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + packagesAbsents = [] + + # Packages + packages = self._flatten(terms[0]) + + # Packages availables sapis + packagesAvailablesSapis = terms[1] + + # Packages presents + packagesPresents = [] + for term in self._flatten(terms[2]): + # package[0] -> Status + # package[1] -> Name + package = term.split(' ') + if package[0] == 'install ok installed' and (package[1].startswith('php-') or re.search('^php[1-9]+', package[1])): + packagesPresents.append(package[1]) + + # Packages dependencies + packagesDependencies = [] + for term in self._flatten(terms[3]): + if not term.startswith('Package '): + packagesDependencies = list(set(packagesDependencies) | set(term.split())) + + # Exclusive - Sapis + exclusiveSapis = terms[4] + + if exclusiveSapis: + # Packages sapis we *WANT* + packagesSapis = list(set(packages) & set(packagesAvailablesSapis)) + # Packages sapis *ALREADY PRESENTS* + packagesSapisPresents = list(set(packagesPresents) & set(packagesAvailablesSapis)) + + # Simple diff to get packages sapis we *DON'T WANT* + packagesAbsents += list(set(packagesSapisPresents) - set(packagesSapis)) + + # Exclusive - Extensions + exclusiveExtensions = terms[5] + + if exclusiveExtensions: + # Packages extensions we *WANT* + packagesExtensions = list(set(packages) - set(packagesAvailablesSapis)) + # Packages extensions *ALREADY PRESENTS* + packagesExtensionsPresents = list(set(packagesPresents) - set(packagesAvailablesSapis)) + + packagesAbsents += list(set(packagesExtensionsPresents) - set(packagesExtensions)) + + # Remove packages dependencies + packagesAbsents = list(set(packagesAbsents) - set(packagesDependencies)) + + return packagesAbsents diff --git a/plugins/lookup/php_sapis.py b/plugins/lookup/php_sapis.py new file mode 100644 index 000000000..98b41d5a5 --- /dev/null +++ b/plugins/lookup/php_sapis.py @@ -0,0 +1,99 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: php_sapis + author: Manala (@manala) + short_description: returns a curated sapis list + description: + - Takes an sapis list and returns it curated and optionally state filtered. + options: + wantstate: + description: filter list items by enabled + wantmap: + description: format result list as a map +''' + + +from ansible.plugins.lookup import LookupBase +from ansible.module_utils.six import string_types +from ansible.errors import AnsibleError +from ansible.module_utils._text import to_text + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + wantstate = kwargs.pop('wantstate', None) + + if wantstate and wantstate not in ['present', 'absent']: + raise AnsibleError('Expected a wanstate of "present" or "absent" but was "%s"' % to_text(wantstate)) + + wantmap = kwargs.pop('wantmap', False) + + sapis = self._flatten(terms[0]) + sapisAvailable = terms[1] + + itemDefault = { + 'state': 'present' + } + + for sapi in sapis: + + items = [] + + # Short syntax + if isinstance(sapi, string_types): + item = itemDefault.copy() + item.update({ + 'sapi': sapi + }) + else: + + # Must be a dict + if not isinstance(sapi, dict): + raise AnsibleError('Expected a dict but was a %s' % type(sapi)) + + # Check index key + if 'sapi' not in sapi: + raise AnsibleError('Missing "sapi" key') + + item = itemDefault.copy() + item.update(sapi) + + # Known sapi ? + if item['sapi'] not in sapisAvailable: + raise AnsibleError('Unknown "%s" sapi' % item['sapi']) + + if item['state'] not in ['present', 'absent', 'ignore']: + raise AnsibleError('Expected a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) + + if item['state'] == 'ignore': + continue + + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['sapi'] == item['sapi']: + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + # Filter by state + if wantstate is not None: + results = [result for result in results if result.get('state') == wantstate] + + # Map + if wantmap: + results = [result.get('sapi') for result in results] + + return results diff --git a/plugins/lookup/ssh_known_hosts.py b/plugins/lookup/ssh_known_hosts.py new file mode 100644 index 000000000..2d6a36da3 --- /dev/null +++ b/plugins/lookup/ssh_known_hosts.py @@ -0,0 +1,72 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: ssh_known_hosts + author: Manala (@manala) + short_description: returns a curated known hosts list + description: + - Takes a known hosts list and returns it curated. +''' + +from ansible.plugins.lookup import LookupBase +from ansible.module_utils.six import string_types +from ansible.errors import AnsibleError + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + hosts = self._flatten(terms[0]) + patterns = terms[1] + + itemDefault = {} + + for host in hosts: + + items = [] + + # Short syntax + if isinstance(host, string_types): + item = itemDefault.copy() + item.update(patterns.get(host)) + else: + + # Must be a dict + if not isinstance(host, dict): + raise AnsibleError('Expected a dict but was a %s' % type(host)) + + # Check index key + if 'host' not in host: + raise AnsibleError('Missing "host" key') + + item = itemDefault.copy() + item.update(host) + + # File + if 'file' in item: + item.pop('key', None) + # Relative + if not item.get('file').startswith('/'): + item.update({ + 'file': variables['role_path'] + '/' + item.get('file') + }) + + items.append(item) + + # Merge by index key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['host'] == item['host']: + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + return results diff --git a/plugins/lookup/templates_exclusive.py b/plugins/lookup/templates_exclusive.py new file mode 100644 index 000000000..6102d60d2 --- /dev/null +++ b/plugins/lookup/templates_exclusive.py @@ -0,0 +1,101 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +DOCUMENTATION = ''' + name: templates_exclusive + author: Manala (@manala) + short_description: returns a curated exlusive templates list + description: + - Takes an exlusive templates list and returns it curated and optionally state filtered. + options: + wantstate: + description: filter list items by state +''' + +from ansible.errors import AnsibleError +from ansible.plugins.lookup import LookupBase +from ansible.module_utils._text import to_text + +import os.path + + +class LookupModule(LookupBase): + + def run(self, terms, variables=None, **kwargs): + + results = [] + + wantstate = kwargs.pop('wantstate', None) + + if wantstate and wantstate not in ['present', 'absent']: + raise AnsibleError('Expected a wanstate of "present" or "absent" but was "%s"' % to_text(wantstate)) + + templates = self._flatten(terms[0]) + exclusives = self._flatten(terms[1]) + dir = terms[2] + template = terms[3] + + itemDefault = { + 'state': 'present', + 'template': template + } + + # Mark exclusive templates as absent + for template in exclusives: + item = itemDefault.copy() + item.update({ + 'file': template['path'], + 'state': 'absent' + }) + results.append(item) + + for template in templates: + + items = [] + + # Must be a dict + if not isinstance(template, dict): + raise AnsibleError('Expected a dict but was a %s' % type(template)) + + # Check file key + if 'file' not in template: + # File name based on template + if 'template' in template: + template['file'] = os.path.splitext( + os.path.basename(template['template']) + )[0] + else: + raise AnsibleError('Missing "file" key') + + item = itemDefault.copy() + item.update(template) + + if item['state'] not in ['present', 'absent', 'ignore']: + raise AnsibleError('Expected a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) + + if item['state'] == 'ignore': + continue + + item.update({ + 'file': os.path.join(dir, item['file']) + }) + + items.append(item) + + # Merge by file key + for item in items: + itemFound = False + for i, result in enumerate(results): + if result['file'] == item['file']: + results[i] = item + itemFound = True + break + + if not itemFound: + results.append(item) + + # Filter by state + if wantstate: + results = [result for result in results if result.get('state') == wantstate] + + return results diff --git a/plugins/modules/files_attributes.py b/plugins/modules/files_attributes.py new file mode 100644 index 000000000..ba7896e39 --- /dev/null +++ b/plugins/modules/files_attributes.py @@ -0,0 +1,25 @@ +#!/usr/bin/python + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +# This is a virtual module that is entirely implemented as an action plugin and runs on the controller + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = r''' +--- +module: files_attributes +author: Manala (@manala) +short_description: Manage files attributes +description: + - Manage files attributes +''' + +EXAMPLES = r''' +- name: Touch file + manala.roles.files_attributes: + path: /tmp/touch + state: touch +''' diff --git a/prepare_collection.py b/prepare_collection.py deleted file mode 100755 index 955faeea8..000000000 --- a/prepare_collection.py +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/env python3 - -import os -import shutil -import pathlib -import re -import logging - -logging.basicConfig(level=logging.INFO) - -collection_dir = 'collection' -meta_dir = os.path.join(collection_dir, 'meta') - -######### -# Clean # -######### - -logging.info('Remove collection dir "%s"', collection_dir) -if os.path.isdir(collection_dir): - shutil.rmtree(collection_dir) - -######## -# Root # -######## - -logging.info('Create collection dir "%s"', collection_dir) -os.makedirs(collection_dir) - -logging.info('Create collection dir "%s"', meta_dir) -os.makedirs(meta_dir) - -logging.info('Copy runtime file into "%s"', meta_dir) -shutil.copyfile( - 'runtime.yml', - os.path.join(meta_dir, 'runtime.yml') -) - -logging.info('Copy galaxy file into "%s"', collection_dir) -shutil.copyfile( - 'galaxy.yml', - os.path.join(collection_dir, 'galaxy.yml') -) - -logging.info('Copy README file into "%s"', collection_dir) -shutil.copyfile( - 'README_COLLECTION.md', - os.path.join(collection_dir, 'README.md') -) - -for plugins_dir in ['lookup', 'callback', 'filter', 'modules', 'action']: - plugins_dir = os.path.join(collection_dir, 'plugins', plugins_dir) - logging.info('Create plugins dir "%s"', plugins_dir) - os.makedirs(plugins_dir) - -######### -# Roles # -######### - -roles_dir = os.path.join(collection_dir, 'roles') - -for role_path in pathlib.Path('roles').glob('*'): - role = os.path.basename(role_path) - role_dir = os.path.join(roles_dir, role) - logging.info('Create role dir "%s"', role_dir) - os.makedirs(role_dir) - # Files - for file in ['CHANGELOG.md', 'README.md']: - file_src = os.path.join('roles', role, file) - if os.path.isfile(file_src): - shutil.copy( - file_src, - os.path.join(role_dir, file) - ) - # Dirs - for dir in ['defaults', 'files', 'handlers', 'meta', 'tasks', 'templates', 'vars']: - dir_src = os.path.join('roles', role, dir) - if os.path.isdir(dir_src): - shutil.copytree( - dir_src, - os.path.join(role_dir, dir) - ) - # Plugins - for plugins in [ - {'src': 'lookup_plugins', 'dst': 'lookup'}, - {'src': 'callback_plugins', 'dst': 'callback'}, - {'src': 'filter_plugins', 'dst': 'filter'}, - {'src': 'library', 'dst': 'modules'}, - {'src': 'action_plugins', 'dst': 'action'} - ]: - for src in pathlib.Path('roles', role, plugins['src']).glob('*.py'): - # Copy - dst = os.path.join( - collection_dir, - 'plugins', - plugins['dst'], - re.sub(r'manala_', r'', os.path.basename(src)) - ) - logging.info('Copy plugin file "%s" into "%s"', src, dst) - shutil.copyfile(src, dst) - # Filters - if plugins['src'] == 'filter_plugins': - regex = re.compile(r'(\')manala_', re.DOTALL) - with open(dst, 'r+') as file: - file_data = file.read() - if len(re.findall(regex, file_data)): - logging.info('Apply filter regex into file "%s"', dst) - file.seek(0) - file.write(re.sub(regex, r'\1', file_data)) - file.truncate() - # Lookups - files = [] - files.extend(pathlib.Path(role_dir, 'handlers').rglob('*.yml')) - files.extend(pathlib.Path(role_dir, 'tasks').rglob('*.yml')) - files.extend(pathlib.Path(role_dir, 'templates').rglob('*.j2')) - regex = re.compile(r'(query\(\s*\')manala_', re.DOTALL) - for file_path in files: - with open(file_path, 'r+') as file: - file_data = file.read() - if len(re.findall(regex, file_data)): - logging.info('Apply lookup regex into file "%s"', file_path) - file.seek(0) - file.write(re.sub(regex, r'\1manala.roles.', file_data)) - file.truncate() - # Filters - files = [] - files.extend(pathlib.Path(role_dir, 'tasks').rglob('*.yml')) - files.extend(pathlib.Path(role_dir, 'templates').rglob('*.j2')) - files.extend(pathlib.Path(role_dir, 'vars').rglob('*.yml')) - regex = re.compile(r'(\|\s*)manala_', re.DOTALL) - for file_path in files: - with open(file_path, 'r+') as file: - file_data = file.read() - if len(re.findall(regex, file_data)): - logging.info('Apply filter regex into file "%s"', file_path) - file.seek(0) - file.write(re.sub(regex, r'\1manala.roles.', file_data)) - file.truncate() - # Actions - files = [] - files.extend(pathlib.Path(role_dir, 'tasks').rglob('*.yml')) - regex = r"^(\s+)manala_(\S+:)$" - for file_path in files: - with open(file_path, 'r+') as file: - file_data = file.read() - if len(re.findall(regex, file_data, re.MULTILINE)): - logging.info('Apply action regex into file "%s"', file_path) - file.seek(0) - file.write(re.sub(regex, "\\1manala.roles.\\2", file_data, 0, re.MULTILINE)) - file.truncate() diff --git a/roles/accounts/.gitignore b/roles/accounts/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/accounts/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/accounts/.manala/make/Makefile b/roles/accounts/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/accounts/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/accounts/.manala/make/Makefile.docker b/roles/accounts/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/accounts/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/accounts/.manala/make/Makefile.host b/roles/accounts/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/accounts/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/accounts/.manala/make/Makefile.manala b/roles/accounts/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/accounts/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/accounts/.manala/make/Makefile.travis b/roles/accounts/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/accounts/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/accounts/.manala/make/gmsl/__gmsl b/roles/accounts/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/accounts/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/accounts/.manala/make/gmsl/gmsl b/roles/accounts/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/accounts/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/accounts/.travis.yml b/roles/accounts/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/accounts/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/accounts/CHANGELOG.md b/roles/accounts/CHANGELOG.md deleted file mode 100644 index 18b0046cd..000000000 --- a/roles/accounts/CHANGELOG.md +++ /dev/null @@ -1,71 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.7] - 2021-11-03 -### Added -- Add trusted GPG public keys - -## [2.0.6] - 2020-10-26 -### Added -- Flatten groups array -- Flatten users array - -## [2.0.5] - 2020-08-26 -### Changed -- Explicit file permissions - -## [2.0.4] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.3] - 2020-01-22 -## Fixed -- User & group state handling - -## [2.0.2] - 2020-01-16 -## Added -- Enhance state option to handle users keys - -## [2.0.1] - 2019-11-29 -### Changed -- Update 'lookup' to use 'query' -- Minimum required version of ansible up to 2.5.0 - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.5] - 2019-10-29 -### Added -- State option to handle users accounts - -## [1.0.4] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.3] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.2] - 2018-06-05 -### Changed -- Replace deprecated jinja tests used as filters -- Replace deprecated uses of "include" - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support - -### Changed -- Tests on default user shell have been removed according to a debian stretch bug, - where default user shell is empty (see: https://github.com/manala/ansible-roles/issues/63) - -## [1.0.0] - 2017-05-12 -### Added -- Handle groups -- Handle users diff --git a/roles/accounts/Makefile b/roles/accounts/Makefile deleted file mode 100644 index c874a1902..000000000 --- a/roles/accounts/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.accounts -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/accounts/README.md b/roles/accounts/README.md index 7882b877e..13322dc57 100644 --- a/roles/accounts/README.md +++ b/roles/accounts/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Accounts [![Build Status](https://travis-ci.org/manala/ansible-role-accounts.svg?branch=master)](https://travis-ci.org/manala/ansible-role-accounts) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Accounts This role will deal with the setup of users and groups accounts and ssh keys. -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,39 +14,15 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.accounts -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.accounts -``` - -## Role Handlers - -None +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| ----------------------------------------- | ------- | ----------- | ----------------------------------------------------------- | -| `manala_accounts_users` | Array | Array | List of unix users. | -| `manala_accounts_users.user` | - | String | Username. | -| `manala_accounts_users.group` | - | String | User's primary group. | -| `manala_accounts_users.groups` | - | Array | Array of user's secondary groups. | -| `manala_accounts_groups` | - | Array | Array of groups to be created. | -| `manala_accounts_groups.name` | - | String | Name of the group to manage. | -| `manala_accounts_groups.system` | - | Boolean | If yes, indicates that the group created is a system group. | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Defining users -The `manala_accounts_users`key will allow to define our users by: +The `manala_accounts_users` will allow to define our users by: - A user name - A main group @@ -70,28 +34,30 @@ The `manala_accounts_users`key will allow to define our users by: ```yaml manala_accounts_users: - - user: foo - group: users + - foo # Short syntax + - user: foo + group: users groups: ['sudo'] authorized_keys_file: authorized_keys2 # authorized_keys by default authorized_keys: - - "{{ query('file', playbook_dir ~ '/files/users/keys/foo@example.com.pub') }}" - - "no-port-forwarding,from=\"10.0.1.*\" {{ query('file', playbook_dir ~ '/files/users/keys/bar@example.com.pub') }}" + - "{{ lookup('file', 'files/users/keys/foo@example.com.pub') }}" + - "no-port-forwarding,from=\"10.0.1.*\" {{ lookup('file', 'files/users/keys/bar@example.com.pub') }}" keys: - - name: id_rsa - public: "{{ query('file', playbook_dir ~ '/files/users/keys/foo@example.com.pub') }}" - private: "{{ query('file', playbook_dir ~ '/files/users/keys/foo@example.com') }}" + - key: id_rsa + public: "{{ lookup('file', 'files/users/keys/foo@example.com.pub') }}" + private: "{{ lookup('file', 'files/users/keys/foo@example.com') }}" gpg_keys: - - key: FOOOBAAR - public: "{{ query('file', playbook_dir ~ '/files/users/gpg_keys/foo@example.com.pub') }}" - secret: "{{ query('file', playbook_dir ~ '/files/users/gpg_keys/foo@example.com') }}" + - key: XXXXXXXXXXXXXXXX + public: "{{ lookup('file', 'files/users/gpg_keys/foo@example.com.pub') }}" + secret: "{{ lookup('file', 'files/users/gpg_keys/foo@example.com') }}" + trust: true # Trust gpg key ``` #### Example: Ensure a user is not present ```yaml manala_accounts_users: - - user: bar - state: absent + - user: bar + state: absent # Flatten users - "{{ my_custom_users_array }}" ``` @@ -112,13 +78,20 @@ You can create your own group by using the `manala_accounts_groups` by specifyin - A group name - If the group is a "system group" +- A state (present|absent|ignore) #### Example ```yaml manala_accounts_groups: - - group: ops - system: false + - foo # Short syntax + - group: foo + - group: foo + system: true + - group: foo + state: absent # Ensure group is absent + - group: foo + state: ignore # Ignore entry # Flatten groups - "{{ my_custom_groups_array }}" ``` @@ -127,13 +100,16 @@ manala_accounts_groups: ```yaml - hosts: servers - roles: - - role: manala.accounts + tasks: + - import_role: + name: manala.roles.accounts ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/accounts/lookup_plugins/.gitignore b/roles/accounts/lookup_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/accounts/lookup_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/accounts/lookup_plugins/manala_accounts_users_authorized_keys.py b/roles/accounts/lookup_plugins/manala_accounts_users_authorized_keys.py deleted file mode 100644 index 723a9a90b..000000000 --- a/roles/accounts/lookup_plugins/manala_accounts_users_authorized_keys.py +++ /dev/null @@ -1,75 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -import os.path - -from ansible.plugins.lookup import LookupBase -from ansible.module_utils.six import string_types -from ansible.errors import AnsibleError - -class LookupModule(LookupBase): - - def run(self, terms, variables=None, **kwargs): - - results = [] - - wantstate = kwargs.pop('wantstate', None) - - users = self._flatten(terms) - - for user in users: - - # Must be a dict - if not isinstance(user, dict): - raise AnsibleError('Expect a dict') - - # Check index key - if 'user' not in user: - raise AnsibleError('Expect "user" key') - - items = [] - - if 'authorized_keys' in user: - item = { - 'user': user.get('user'), - 'authorized_keys': '\n'.join(user.get('authorized_keys')), - 'state': user.get('state', 'present'), - } - - # File - if 'authorized_keys_file' in user and user.get('authorized_keys_file'): - # Omit - if user.get('authorized_keys_file') == variables['omit']: - pass - # Path - elif isinstance(user.get('authorized_keys_file'), string_types): - # Absolute - if user.get('authorized_keys_file').startswith('/'): - item.update({ - 'authorized_keys_file': user.get('authorized_keys_file') - }) - # Relative - else: - item.update({ - 'authorized_keys_file': os.path.expanduser('~' + user.get('user') + '/.ssh/' + user.get('authorized_keys_file')) - }) - - items.append(item) - - # Merge by index key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['user'] == item['user']: - results[i] = item - itemFound = True - break - - if not itemFound: - results.append(item) - - # Filter by state - if wantstate: - results = [result for result in results if result.get('state') == wantstate] - - return results diff --git a/roles/accounts/meta/main.yml b/roles/accounts/meta/main.yml index fe960c6e0..e0ff0c73e 100644 --- a/roles/accounts/meta/main.yml +++ b/roles/accounts/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: accounts - author: Manala - company: Manala - description: Handle accounts users and groups - license: MIT - min_ansible_version: 2.5.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: accounts + author: Manala + company: Manala + description: Handle accounts users and groups + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - accounts diff --git a/roles/accounts/tasks/groups.yml b/roles/accounts/tasks/groups.yml index afe408ca6..d4d2c51e2 100644 --- a/roles/accounts/tasks/groups.yml +++ b/roles/accounts/tasks/groups.yml @@ -6,4 +6,8 @@ system: "{{ item.system|default(omit) }}" state: "{{ item.state|default('present') }}" gid: "{{ item.gid|default(omit) }}" - with_items: "{{ manala_accounts_groups|flatten }}" + loop: "{{ + manala_accounts_groups + | flatten + | manala.roles.staten + }}" diff --git a/roles/accounts/tasks/users.yml b/roles/accounts/tasks/users.yml index 221e12678..22498566c 100644 --- a/roles/accounts/tasks/users.yml +++ b/roles/accounts/tasks/users.yml @@ -1,8 +1,8 @@ --- -- name: users > Accounts +- name: users > Users configuration user: - name: "{{ item.user }}" + name: "{{ (item) if (item is string) else (item.user) }}" password: "{{ item.password|default(omit) }}" group: "{{ item.group|default(omit) }}" groups: "{{ item.groups|default([])|join(',') }}" @@ -13,7 +13,16 @@ uid: "{{ item.uid|default(omit) }}" comment: "{{ item.comment|default(omit) }}" state: "{{ item.state|default('present') }}" - with_items: "{{ manala_accounts_users|flatten }}" + loop: "{{ + manala_accounts_users + | flatten + | manala.roles.staten + }}" + loop_control: + label: "{{ { + 'user': (item) if (item is string) else (item.user), + 'state': item.state|default('present'), + } }}" - name: users > Authorized keys authorized_key: @@ -22,99 +31,118 @@ path: "{{ item.authorized_keys_file|default(omit) }}" exclusive: true loop: "{{ query( - 'manala_accounts_users_authorized_keys', - manala_accounts_users|flatten, - wantstate='present' - ) - }}" + 'manala.roles.accounts_users_authorized_keys', + manala_accounts_users + | flatten + | manala.roles.staten(want='present') + ) }}" + loop_control: + label: "{{ { + 'user': item.user, + } }}" # Find the primary group of users whose group has not been manually defined - name: users > Find primary groups - command: "id -g -n {{ item.user }}" - with_items: "{{ manala_accounts_users|flatten }}" - when: item.group is not defined and item.state|default('present') == 'present' - register: __manala_accounts_users + command: > + id -g -n {{ item.user }} + loop: "{{ + manala_accounts_users + | flatten + | manala.roles.staten(want='present') + | selectattr('keys', 'sequence') | list + }}" + loop_control: + label: "{{ { + 'user': (item) if (item is string) else (item.user), + } }}" + when: + - item is not string + - item.group is not defined + register: __manala_accounts_users_groups changed_when: false - no_log: true - -# Pair users with their found groups -- name: users > Pair primary groups - set_fact: - # Waiting for the ansible 2 "combine" filter... - __item: "{% set __item = item.0.update(({}) if (item.1 is skipped) else ({'group': item.1.stdout})) %}{{ item.0 }}" - with_together: - - "{{ manala_accounts_users|flatten }}" - - "{{ __manala_accounts_users.results }}" - register: __manala_accounts_users - no_log: true - -# Flatten results structure to the original variable -- name: users > Flatten primary groups - set_fact: - manala_accounts_users: "{{ __manala_accounts_users.results|map(attribute='ansible_facts.__item')|list }}" - no_log: true - name: users > Keys directory file: - path: "~{{ item.0.user }}/.ssh" + path: "~{{ item.user }}/.ssh" state: directory - owner: "{{ item.0.user }}" - group: "{{ item.0.group|default(omit) }}" + owner: "{{ item.user }}" + group: "{{ item.group|default(omit) }}" mode: "0700" - with_subelements: - - "{{ manala_accounts_users|selectattr('keys', 'sequence')|list }}" - - keys - -- name: users > Keys private - copy: - dest: "~{{ item.0.user }}/.ssh/{{ item.1.key|default('id_rsa') }}" - content: "{{ item.1.private }}" - owner: "{{ item.0.user }}" - group: "{{ item.0.group|default(omit) }}" - mode: "0600" - when: item.1.private is defined - with_subelements: - - "{{ manala_accounts_users|selectattr('keys', 'sequence')|list }}" - - keys + loop: "{{ + manala_accounts_users + | flatten + | manala.roles.staten(want='present') + | selectattr('keys', 'sequence') + | manala.roles.users_groups(__manala_accounts_users_groups.results) + }}" + loop_control: + label: "{{ { + 'user': item.user, + } }}" -- name: users > Keys public +- name: users > Keys copy: - dest: "~{{ item.0.user }}/.ssh/{{ item.1.key|default('id_rsa') }}.pub" - content: "{{ item.1.public }}" - owner: "{{ item.0.user }}" - group: "{{ item.0.group|default(omit) }}" - mode: "0644" - when: item.1.public is defined - with_subelements: - - "{{ manala_accounts_users|selectattr('keys', 'sequence')|list }}" - - keys - -- name: users > Gpg keys public - command: "su {{ item.0.user }} -c 'gpg --list-keys {{ item.1.key }} || echo \"{{ item.1.public }}\" | gpg --import'" - when: item.1.public is defined - register: __manala_accounts_users_gpg_keys_public_result - changed_when: __manala_accounts_users_gpg_keys_public_result.stderr - with_subelements: - - "{{ manala_accounts_users|selectattr('gpg_keys', 'sequence')|list }}" - - gpg_keys - no_log: true - -- name: users > Gpg keys secret - command: "su {{ item.0.user }} -c 'gpg --list-secret-keys {{ item.1.key }} || echo \"{{ item.1.secret }}\" | gpg --import --allow-secret-key-import'" - when: item.1.secret is defined - register: __manala_accounts_users_gpg_keys_secret_result - changed_when: __manala_accounts_users_gpg_keys_secret_result.stderr - with_subelements: - - "{{ manala_accounts_users|selectattr('gpg_keys', 'sequence')|list }}" - - gpg_keys - no_log: true + dest: "~{{ item.0.0.user }}/.ssh/{{ item.0.1.key|default('id_rsa') ~ {'private': '', 'public': '.pub'}[item.1] }}" + content: "{{ item.0.1[item.1] }}" + owner: "{{ item.0.0.user }}" + group: "{{ item.0.0.group|default(omit) }}" + mode: "{{ {'private': '0600', 'public': '0644'}[item.1] }}" + when: item.0.1[item.1] is defined + loop: "{{ + manala_accounts_users + | flatten + | manala.roles.staten(want='present') + | selectattr('keys', 'sequence') + | manala.roles.users_groups(__manala_accounts_users_groups.results) + | subelements('keys') + | product(['private', 'public']) + | list + }}" + loop_control: + label: "{{ { + 'user': item.0.0.user, + 'key': item.0.1.key|default('id_rsa'), + 'type': item.1, + } }}" -- name: users > Gpg trust keys public - command: "su {{ item.0.user }} -c 'echo \"{{ item.1.public }}\" | gpg --keyid-format long --with-fingerprint --with-colons - | sed -E -n -e \"s/^fpr:::::::::([0-9A-F]+):$/\\1:6:/p\" | gpg --import-ownertrust'" - when: item.1.public is defined and item.1.trust is defined - register: __manala_accounts_users_gpg_trust_keys_public_result - changed_when: "'gpg: WARNING: no command supplied. Trying to guess what you mean ...' not in __manala_accounts_users_gpg_trust_keys_public_result.stderr" - with_subelements: - - "{{ manala_accounts_users|selectattr('gpg_keys', 'sequence')|list }}" - - gpg_keys - no_log: true +- name: users > Gpg keys + command: > + su {{ item.0.0.user }} -c ' + {%- if item.1 == 'public' -%} + gpg --list-keys {{ item.0.1.key }} || echo "{{ item.0.1.public }}" \ + | gpg --import + {%- if item.0.1.trust|default(False) -%}{{- ' ' -}} + && echo "{{ item.0.1.public }}" \ + | gpg --keyid-format long --with-fingerprint --with-colons - \ + | sed -E -n -e "s/^fpr:::::::::([0-9A-F]+):$/\\1:6:/p" \ + | gpg --import-ownertrust + {%- endif -%} + {%- else -%} + gpg --list-secret-keys {{ item.0.1.key }} || echo "{{ item.0.1.secret }}" \ + | gpg --import --allow-secret-key-import + {%- endif -%} + ' + when: item.0.1[item.1] is defined + register: __manala_accounts_users_gpg_keys + changed_when: + - __manala_accounts_users_gpg_keys.stderr + - | + 'gpg: WARNING: no command supplied.' not in __manala_accounts_users_gpg_keys.stderr + or + 'gpg: inserting ownertrust of' in __manala_accounts_users_gpg_keys.stderr + loop: "{{ + manala_accounts_users + | flatten + | manala.roles.staten(want='present') + | selectattr('gpg_keys', 'sequence') | list + | subelements('gpg_keys') + | product(['public', 'secret']) + | list + }}" + loop_control: + label: "{{ { + 'user': item.0.0.user, + 'key': item.0.1.key, + 'trust': item.0.1.trust|default(False), + 'type': item.1, + } }}" diff --git a/roles/accounts/tests/.gitignore b/roles/accounts/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/accounts/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/accounts/tests/0200_users.goss.yml b/roles/accounts/tests/0200_users.goss.yml deleted file mode 100644 index a6030c72f..000000000 --- a/roles/accounts/tests/0200_users.goss.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- - -group: - group_1: - exists: true - group_2: - exists: true - user_5: - exists: true - user_6: - exists: true - user_7: - exists: true - user_8: - exists: true - -user: - user_1: - exists: true - home: /home/user_1 - groups: - - group_1 - user_2: - exists: true - home: /home/user_2 - groups: - - group_2 - - group_1 - user_3: - exists: true - home: /home/user_3 - groups: - - users - user_4: - exists: true - home: /home/user_4 - groups: - - users - user_5: - exists: true - home: /home/user_5 - groups: - - user_5 - user_6: - exists: true - home: /home/user_6 - groups: - - user_6 - user_7: - exists: true - home: /home/user_7 - groups: - - user_7 - user_8: - exists: true - home: /home/user_8 - groups: - - user_8 - -file: - /home/user_1/.ssh/authorized_keys: - exists: true - filetype: file - owner: user_1 - group: group_1 - mode: "0600" - contains: - - "{{ readFile "fixtures/keys/user_1.pub" }}" - - "!{{ readFile "fixtures/keys/user_2.pub" }}" - - "!{{ readFile "fixtures/keys/user_3.pub" }}" - /home/user_2/.ssh/authorized_keys: - exists: true - filetype: file - owner: user_2 - group: group_2 - mode: "0600" - contains: - - "{{ readFile "fixtures/keys/user_1.pub" }}" - - "{{ readFile "fixtures/keys/user_2.pub" }}" - - "!{{ readFile "fixtures/keys/user_3.pub" }}" - /home/user_3/.ssh/authorized_keys: - exists: false - filetype: file - /home/user_3/.ssh/authorized_keys2: - exists: true - filetype: file - owner: user_3 - group: users - mode: "0600" - contains: - - "!{{ readFile "fixtures/keys/user_1.pub" }}" - - "{{ readFile "fixtures/keys/user_2.pub" }}" - - "{{ readFile "fixtures/keys/user_3.pub" }}" - /home/user_4/.ssh/authorized_keys: - exists: false - filetype: file - /home/user_4/.ssh/authorized_keys3: - exists: true - filetype: file - owner: user_4 - group: users - mode: "0600" - contains: - - "!{{ readFile "fixtures/keys/user_1.pub" }}" - - "{{ readFile "fixtures/keys/user_2.pub" }}" - - "{{ readFile "fixtures/keys/user_3.pub" }}" - /home/user_5/.ssh/authorized_keys: - exists: false - filetype: file - /home/user_6/.ssh/authorized_keys: - exists: true - filetype: file - owner: user_6 - group: user_6 - mode: "0600" - contains: - - "{{ readFile "fixtures/keys/user_1.pub" }}" - /home/user_7/.ssh/authorized_keys: - exists: true - filetype: file - owner: user_7 - group: user_7 - mode: "0600" - contains: - - "{{ readFile "fixtures/keys/user_1.pub" }}" diff --git a/roles/accounts/tests/0200_users.yml b/roles/accounts/tests/0200_users.yml deleted file mode 100644 index 431912819..000000000 --- a/roles/accounts/tests/0200_users.yml +++ /dev/null @@ -1,55 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_accounts_groups: - - group_1 - # Flatten - - - - group_2 - manala_accounts_users: - - user: user_1 - group: group_1 - authorized_keys: - - "{{ lookup('file', playbook_dir ~ '/fixtures/keys/user_1.pub') }}" - - user: user_2 - group: group_2 - groups: - - group_1 - authorized_keys: - - "{{ lookup('file', playbook_dir ~ '/fixtures/keys/user_1.pub') }}" - - "{{ lookup('file', playbook_dir ~ '/fixtures/keys/user_2.pub') }}" - - user: user_3 - group: users - authorized_keys_file: authorized_keys2 - authorized_keys: - - "{{ lookup('file', playbook_dir ~ '/fixtures/keys/user_2.pub') }}" - - "{{ lookup('file', playbook_dir ~ '/fixtures/keys/user_3.pub') }}" - - user: user_4 - group: users - authorized_keys_file: /home/user_4/.ssh/authorized_keys3 - authorized_keys: - - "{{ lookup('file', playbook_dir ~ '/fixtures/keys/user_2.pub') }}" - - "{{ lookup('file', playbook_dir ~ '/fixtures/keys/user_3.pub') }}" - - user: user_5 - # Flatten - - - - user: user_6 - authorized_keys_file: "{{ omit }}" - authorized_keys: - - "{{ lookup('file', playbook_dir ~ '/fixtures/keys/user_1.pub') }}" - - user: user_7 - authorized_keys_file: ~ - authorized_keys: - - "{{ lookup('file', playbook_dir ~ '/fixtures/keys/user_1.pub') }}" - - user: user_8 - authorized_keys_file: "" - authorized_keys: - - "{{ lookup('file', playbook_dir ~ '/fixtures/keys/user_1.pub') }}" - roles: - - manala.accounts - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/accounts/tests/0201_users_absents.goss.yml b/roles/accounts/tests/0201_users_absents.goss.yml deleted file mode 100644 index 17cd56c2a..000000000 --- a/roles/accounts/tests/0201_users_absents.goss.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -group: - to_preserve: - exists: true - to_delete: - exists: true - -user: - user_1: - exists: false - home: /home/user_1 - user_2: - exists: true - home: /home/user_2 - user_3: - exists: false diff --git a/roles/accounts/tests/0201_users_absents.yml b/roles/accounts/tests/0201_users_absents.yml deleted file mode 100644 index d55a7c1b1..000000000 --- a/roles/accounts/tests/0201_users_absents.yml +++ /dev/null @@ -1,44 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - pre_tasks: - - name: Pre tasks > Ensure group "to_delete" exists - group: - name: to_delete - state: present - - name: Pre tasks > Ensure group "to_preserve" exists - group: - name: to_preserve - state: present - - name: Pre tasks > Add user user_1 to be deleted. - user: - name: user_1 - group: to_delete - - name: Pre tasks > Add user user_2 to be preserved. - user: - name: user_2 - group: to_preserve - vars: - manala_accounts_users: - - user: user_1 - group: to_delete - authorized_keys: - - "{{ lookup('file', playbook_dir ~ '/fixtures/keys/user_1.pub') }}" - state: absent - - user: user_2 - group: to_preserve - - user: user_3 - group: to_delete - authorized_keys: - - "{{ lookup('file', playbook_dir ~ '/fixtures/keys/user_3.pub') }}" - state: absent - manala_accounts_groups: - - group: to_delete - - group: to_preserve - roles: - - manala.accounts - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/accounts/tests/0202_users_gpg_keys.goss.yml b/roles/accounts/tests/0202_users_gpg_keys.goss.yml deleted file mode 100644 index 402e051ae..000000000 --- a/roles/accounts/tests/0202_users_gpg_keys.goss.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -command: - export-keys: - exec: "su user_1 -c 'gpg --export-ownertrust'" - exit-status: 0 - stdout: - - B71FEBC2AD2888C9A035372DC58B1DF869528F92 - - 7D52C438085B5BB924460165BA0EECE4FA58F7BF diff --git a/roles/accounts/tests/0202_users_gpg_keys.yml b/roles/accounts/tests/0202_users_gpg_keys.yml deleted file mode 100644 index 99c04b29b..000000000 --- a/roles/accounts/tests/0202_users_gpg_keys.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_accounts_users: - - user: user_1 - gpg_keys: - - key: key_1 - public: "{{ lookup('file', playbook_dir ~ '/fixtures/gpg_keys/key_1.gpg.key') }}" - trust: true - - key: key_2 - public: "{{ lookup('file', playbook_dir ~ '/fixtures/gpg_keys/key_2.gpg.key') }}" - trust: true - roles: - - manala.accounts - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/accounts/tests/fixtures/gpg_keys/key_1.gpg.key b/roles/accounts/tests/fixtures/gpg_keys/key_1.gpg.key deleted file mode 100644 index e79c5d366..000000000 --- a/roles/accounts/tests/fixtures/gpg_keys/key_1.gpg.key +++ /dev/null @@ -1,17 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- - -mQENBGFy1YMBCADeAuSVaivUOVu3EigFRPxMJO6LE4ZjEq2YPdshbX0KzTCjE5dW -o8cHhrZGquTUQI+ta9s06iUZr4ew4At8Q9mbiLVzHA1e3WzNwjr7vOeg9f5TgAmy -eUy/VtGCYmbveflzwVUfMxcBvGeOqYb04IDecGq94VdmqpC4HqBQUfO72XfkwhQl -/jy5XzyupvwidOov3qX+mWHUC+V/avSbuXdgsRfog2faavxNzXANJAZPVQZO1oy5 -YZ9y1VHMl0JqqOxwoWbvWFXAIHFO977lIZtMP5bDZwrZH7kfWplLqQOXhl5flp1w -SL5Hqx3Inx7GnZXlapVwRJ+imENPEjBiiZcBABEBAAG0BWtleV8xiQFOBBMBCgA4 -FiEEtx/rwq0oiMmgNTctxYsd+GlSj5IFAmFy1YMCGwMFCwkIBwIGFQoJCAsCBBYC -AwECHgECF4AACgkQxYsd+GlSj5LFeggAsfNz/0L3nrmuXNoF7ZxHSt35T7j2licy -/r02woMCLYs+ZOb8puGwwz5ZaNDcBRGuvF0DEDBwsCqtvakUQmXqI3jvK8v3ID30 -jWNUAxl0i7BirGB1gVvCF5nuYGDZ0DN6pAhnbTEapAJc6Cfndkw5ghETjUE76AaR -mAPfVBIImib/kPzrzo/EyBEeni7aIFemLLQUdxFKe7FeAEAmjylBzhLikojfp98e -FnzCzr/bxJ68hcLCYvZrPtMKW0wvTmOPcCQQQWXZ9qrdk/tMfFSh9hvKsgQwWIsE -m+Q9iD/Tcn0lndoL87OlMXv5P9+j/fqF7ViaGEwv8ULBPVzZKqfksg== -=xA6S ------END PGP PUBLIC KEY BLOCK----- diff --git a/roles/accounts/tests/fixtures/gpg_keys/key_2.gpg.key b/roles/accounts/tests/fixtures/gpg_keys/key_2.gpg.key deleted file mode 100644 index a51784788..000000000 --- a/roles/accounts/tests/fixtures/gpg_keys/key_2.gpg.key +++ /dev/null @@ -1,17 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- - -mQENBGFy1bUBCACXK10iwC9Bky3o9CkGsOhPeNuN3pwl7/KD5bAXvEAFzF2oSDLo -dooVMKUdn/3iDRHeF2TZokwjDcy+7kT7nVKDuZbM2RsU5pA7fODUf4YrFvstNCZB -vkzHMj/o3b5Ae3Sxnln7k0AERyW91mvTpYaFsAuujUqPsRzus+iQ8LUI91bvL5mv -8nzaXrtLKnyt1UfABS9t15GYtp80JI/wNU5AywYtwX83qA+cC2foGu1NJ0nv3l41 -vVGEsmgnmRsMFXAlrMT5eedwec01AGjG461qdrV1Yuj/VIsK6YT1U4AovxYJFNIQ -55d/0cvBKIrKMs1goWXqf5IG8ypmPQVLQuEnABEBAAG0BWtleV8yiQFOBBMBCgA4 -FiEEfVLEOAhbW7kkRgFlug7s5PpY978FAmFy1bUCGwMFCwkIBwIGFQoJCAsCBBYC -AwECHgECF4AACgkQug7s5PpY97+IiAgAiPGdUA4v4i6/ZQVjUwV/vrC5x3PalOm4 -Tn5f07xEY3eaM4ovFrQXxIKGKTQOUSDyrJTWTq26++9GwMjgi7ucG9Yq0bxbvxiF -X443BFOpKkRurzSZLte/5lwJeG1uiXfSGvUjDzzibw2fYl3vlKfBp8GtURm7e5Kw -rUfnxjjfkIqnYTxnt/ZBLlTi5iBiNZzjxrozn0arQd0wTURkFs3sALgnBofJF57l -ggkQp6XbjWvNRb8+qm9bcvbBAh8AYwdLPmnk6TDoW4Wen+/8s2PfQvrsGS/9xeRz -tXalJDtfvrHRhjKWw81y9oOY/F5wosyDC2F01aOTdA91hzMeVDwt6w== -=ufKK ------END PGP PUBLIC KEY BLOCK----- diff --git a/roles/accounts/tests/fixtures/keys/user_3 b/roles/accounts/tests/fixtures/keys/user_3 deleted file mode 100644 index b2da3cd89..000000000 --- a/roles/accounts/tests/fixtures/keys/user_3 +++ /dev/null @@ -1,51 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIJJwIBAAKCAgEAn7KIOeXEZ7KBAtnoXyb8t7UBHhcRrNN9o2YuuePs8obq3n23 -OkLh2d57p+HJ78ZiWDyMZg1qpnXMmhwi63ucz/dxq7GhxD/jNIlsxAloR4Y68DBF -9oYkYWKio6c4+SZPOUm4vP0D8GO8jaVcaqHqAe+vpK144AicLfTtiNNL2sBp7w4V -ZJZCXIDmKKxdTMllaQxvjNDXc3Y37DJmABin0vPIzJXb4ZfEW0ARJj4wjZLMoFpK -+U50PIkXG5/burp9CJufB7utwStpL2F/iV6fssvNhy3aT2oREYdywZsyz1HNnyEI -gZFUTY0mBjYBseiI6ugr2j44UNh65mnc4pcpfFjyCjk9CYr04eJ8ukObWNfDCrdt -kRwuw5tUrO27Ak6PjzA2nx/WUPBdsUTdvQilRcdzw1YDjIH3neZ7v1HqCC9k3sqy -UPFr5Sb4oeOUpdojukJ7izjNBBMnfQGHQFh+n7toy4iR6uFmxf4t8p70JIZ6ccxT -VTCMVMeFk7D2KHZJVTjlcBf6jEMHGtfTNQvJdwr+Vr+gbsLrOKvxoyh5h4oz/5mI -Yg4573A/rLDZ9+xuVdm5/hi4N68Fa3mxorUst5PjYM4ahASkvQiCKkPfWHu8i+kV -jQRU2WyhKEpAEbz1T4gBdvhy55cf+hnz+fn9GJ61uZ7suXevaF6f+wWAW0cCAwEA -AQKCAgAxj6OtbDxm/kQBkYUHOr9FeBwvrXMj0sL0Gfs4X58iqXJsuFFL+IPFLMHt -mSolisjsn2XnKhTGMlrcHQ1NTaCd/io94bPVhwpJPLkPoefGAsd50VF1L65MtuLI -rVYGJLiDi/iUVmWJjjpvLzmeMj/AeBVnoxqXVLS7on6xbvnkmsCFmzZScDuKH8rO -JqgR85LQZjacWhfzUmYKnJ2BPCWhV10i+QMzYPlkZF6uIrDIzx1ISp1n/8wdGWKd -hSAZNFUnfbx+FuXWxFUxii2dgUtInu1bHYTaDo3bhdC8eyDqrHWHBCZyp5qlMr/x -P4OJJiSP2pv5cEPj+zsxFPujKsyJuEQOyVk5JKYGHfdUdyOWK5ppKtSzVgZsgK3A -AqA24UckBmKW4yg992RMleKCyeO9dTls1axOEXFOoHDL4Qa55ZmYo2lO/PdCZel0 -EWPXIzkqqzJVPrD3E/hAuW2zqABWn0OZlS+mNAQLc547FxcO5FT/OQNfVtF5I3lf -uCEpBgfl43KZf4FuUsu84SRGdPmz2C5xg3gUwfyg7W2bgNA+LDq9CKhHwZerveml -1oSotkYc+KwstdCBAAP6rMKRiBlUmPJMVWlyY8xvyrk5yb63AEnuSXbTVMiHEyNM -vGwgOQ9oIjbR/j9i90qsYGUWD/2/GnFACMaKoVlTO34BEYCFcQKCAQEAy1ciAVRA -m/x/Y2iQqU0QzMwL0xhO/e6dUT3RzH1clS1ujpQ9HMBlsd5pWiw4XDaCcbTjUiV3 -P2eJmA2zFY0pOBvAxrrMO/XsWl+o9gpu+8mwcJtm0UT/Q1xmnB3Cbaog1Q+aLBb7 -NdiEFD7Bang1sEju/pHPhIurft9lkcNxze9MiRIjBruRC6ZrI/1sf2SYourI2VPr -1+7ul7Hd+/Vkb5ejsAeapMAL67oaaHjIR+4e8di26o8vg2Io8oCrqZQuWD6As7kX -gDshTOvLkZzFzCax5CzDoTUHbMaBc1GFiOCC/k6JkGJYYm3rlM96tNGpRxv9sRl/ -Rwr+MmI7pPzKXwKCAQEAyQ3/szILrqAKvgtPBFkDkawohon4Fj+dQdeC4Uw6mwLu -RzQ7zVn/o51zkKJ7N0gxcYacqaUEtjRL6tn8p97RCn/NoxNROdga/rgwAlJV5NR7 -ks3F0L2T8q3qXARenjcUQhCIL8tvgSKy2HSaEq/kEfgFTVOpUJz88q0DJQox9EAO -W+qmZL8ttgyMcuLQzVbTB5iWJRyD/9/eqfKz9m87Gcs0CFlW+h3Z1Mgu4kIBjRRL -HCz7YjQSn5lOxzduTtxU5OkkU41Kd500yNQM+La9CjkEjp5W1BDunPS+1U9UuBhC -A5BC2AfibtAK1NKnKAV47kvN2iHgT2EhufBVI6ZoGQKCAQA2G4556hBzMYI4UpfD -5TTmOhmfZ2WFnpwQBTIxht4+9+LmX73PS8cDyJoiG4g3yW12klq2/i84GPX9FxAj -WPex7XijqQs1nV/yQGg2aFpV97pSjJeUcha2tvy66BRXmCC6cTdmKgtYra+fr39K -NIicyxuFdAlTTNMqpIljey1qThYAl2nonbqf7f2uiv32/C69k1o0smccg4DLrtHR -/N9n7mLpMWzOEChb5p6mVBV/RnbHhhJOYiGThWg99002h665XpBiworlXVakIE6A -BcaAZ3+Ipvy7hd/e6weBRx0QaiWRRBbI69J3BqbcZ0VQnkW8HU+pc45xuhQgFhGm -+nljAoIBAHvLi9MpkHngf1zPF8NEj+cFSxq0HzaLyud8rFDPIBLMNi1PozbpIHf8 -/ehjs1yxrggJ67KlMgaCovAjcudmUe6WDOdJgK0OPGj0vlLfoZW5o7Eb1J6X7F3z -6iboZd4jaezXwxMyvyCTXe3btfalqNfLkHAxgEJrt3AxSYtoAKQ1QOIl1HiaIqpC -hcRDlm+o811s/Z4yNbC6hp68G0U07f4O2aX+ZIizEqpq7DtSiyP0B998bvjjuUfe -HNyba+dQ0VD1oPF1QRHvkU3LC4Wk9zcxLnYmVq5TEqlAJbSwGSkVfqg1DoN4L1st -7E1ou5Xv8KtBr6mNTFF0LFESA0plLxkCggEAXZxm0nF0c3rUzY3tbnHfeOh1O7PQ -uweaVMCqZiByF0Nkz3hiV3JLny2P3FKQ1MGFqqX8JOh1AJuUkIs066jj4mpMFMYv -MmAnns2bGJMQV7F0D/bmVpWGohuixDhhFuAMKb7J1F5BZRlzEGXdQ2sF6J5Dr3zx -9/ibk1bGoiBDwmqT5JaYWXYAkFnGdsxTfCq2o+8bMyP3wXEKlaVbV9kJR9+6uaiW -sm+XTlRZEzo+xCt8fEADbg/Ejp/Eer9r5W1gjTvRg4Z8FzYjD01dammLTYgKCAl1 -HXZK+zlt1lk25hJDJtRYeki8k7ErfXZX7WTxnx6SZC0xkfbrxMiRgYAs5g== ------END RSA PRIVATE KEY----- diff --git a/roles/accounts/tests/fixtures/keys/user_3.pub b/roles/accounts/tests/fixtures/keys/user_3.pub deleted file mode 100644 index 4d7f507b5..000000000 --- a/roles/accounts/tests/fixtures/keys/user_3.pub +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCfsog55cRnsoEC2ehfJvy3tQEeFxGs032jZi654+zyhurefbc6QuHZ3nun4cnvxmJYPIxmDWqmdcyaHCLre5zP93GrsaHEP+M0iWzECWhHhjrwMEX2hiRhYqKjpzj5Jk85Sbi8/QPwY7yNpVxqoeoB76+krXjgCJwt9O2I00vawGnvDhVklkJcgOYorF1MyWVpDG+M0NdzdjfsMmYAGKfS88jMldvhl8RbQBEmPjCNksygWkr5TnQ8iRcbn9u6un0Im58Hu63BK2kvYX+JXp+yy82HLdpPahERh3LBmzLPUc2fIQiBkVRNjSYGNgGx6Ijq6CvaPjhQ2Hrmadzilyl8WPIKOT0JivTh4ny6Q5tY18MKt22RHC7Dm1Ss7bsCTo+PMDafH9ZQ8F2xRN29CKVFx3PDVgOMgfed5nu/UeoIL2TeyrJQ8WvlJvih45Sl2iO6QnuLOM0EEyd9AYdAWH6fu2jLiJHq4WbF/i3ynvQkhnpxzFNVMIxUx4WTsPYodklVOOVwF/qMQwca19M1C8l3Cv5Wv6Buwus4q/GjKHmHijP/mYhiDjnvcD+ssNn37G5V2bn+GLg3rwVrebGitSy3k+NgzhqEBKS9CIIqQ99Ye7yL6RWNBFTZbKEoSkARvPVPiAF2+HLnlx/6GfP5+f0YnrW5nuy5d69oXp/7BYBbRw== user_3@group_3.com diff --git a/roles/alternatives/.gitignore b/roles/alternatives/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/alternatives/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/alternatives/.manala/make/Makefile b/roles/alternatives/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/alternatives/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/alternatives/.manala/make/Makefile.docker b/roles/alternatives/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/alternatives/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/alternatives/.manala/make/Makefile.host b/roles/alternatives/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/alternatives/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/alternatives/.manala/make/Makefile.manala b/roles/alternatives/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/alternatives/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/alternatives/.manala/make/Makefile.travis b/roles/alternatives/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/alternatives/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/alternatives/.manala/make/gmsl/__gmsl b/roles/alternatives/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/alternatives/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/alternatives/.manala/make/gmsl/gmsl b/roles/alternatives/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/alternatives/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/alternatives/.travis.yml b/roles/alternatives/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/alternatives/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/alternatives/CHANGELOG.md b/roles/alternatives/CHANGELOG.md deleted file mode 100644 index c7d2aadd6..000000000 --- a/roles/alternatives/CHANGELOG.md +++ /dev/null @@ -1,36 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.1] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.4] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.3] - 2018-06-05 -### Changed -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.2] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.1] - 2017-10-30 -### Changed -- Fix ansible 2.3 warnings "when statements should not include jinja2 templating delimiters" - -## [1.0.0] - 2016-11-30 -### Added -- Handle selections diff --git a/roles/alternatives/Makefile b/roles/alternatives/Makefile deleted file mode 100644 index 67bea5328..000000000 --- a/roles/alternatives/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.alternatives -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/alternatives/README.md b/roles/alternatives/README.md index af09a9e87..8345e5cb8 100644 --- a/roles/alternatives/README.md +++ b/roles/alternatives/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Alternatives [![Build Status](https://travis-ci.org/manala/ansible-role-alternatives.svg?branch=master)](https://travis-ci.org/manala/ansible-role-alternatives) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Alternatives This role will deal with the setup of __alternatives__. -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,25 +14,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.alternatives -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.alternatives -``` +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default| Type | Description | -|------------------------------- |------- |------ |------------- | -| manala_alternatives_selections | [] | Array | Alternatives | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration @@ -54,19 +28,28 @@ Using ansible galaxy requirements file: manala_alternatives_selections: - selection: editor path: /usr/bin/vim.basic + # Ignore selection + - selection: foo + path: /bin/bar + state: ignore + # Flatten selections + - "{{ my_custom_selections_array }}" ``` ## Example playbook ```yaml - hosts: servers - roles: - - { role: manala.alternatives } + tasks: + - import_role: + name: manala.roles.alternatives ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/alternatives/meta/main.yml b/roles/alternatives/meta/main.yml index 0da956f99..b98a0e5a9 100644 --- a/roles/alternatives/meta/main.yml +++ b/roles/alternatives/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: alternatives - author: Manala - company: Manala - description: Handle alternatives - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: alternatives + author: Manala + company: Manala + description: Handle alternatives + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - alternatives diff --git a/roles/alternatives/tasks/selections.yml b/roles/alternatives/tasks/selections.yml index ec4a4df82..66bce1962 100644 --- a/roles/alternatives/tasks/selections.yml +++ b/roles/alternatives/tasks/selections.yml @@ -4,4 +4,8 @@ alternatives: name: "{{ item.selection }}" path: "{{ item.path }}" - with_items: "{{ manala_alternatives_selections }}" + loop: "{{ + manala_alternatives_selections + | flatten + | manala.roles.staten(want='present') + }}" diff --git a/roles/alternatives/tests/.gitignore b/roles/alternatives/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/alternatives/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/alternatives/tests/0100_selections.goss.yml b/roles/alternatives/tests/0100_selections.goss.yml deleted file mode 100644 index 30d3616ca..000000000 --- a/roles/alternatives/tests/0100_selections.goss.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -command: - update-alternatives --query editor: - exit-status: 0 - stdout: - - "Value: /bin/ed" diff --git a/roles/alternatives/tests/0100_selections.yml b/roles/alternatives/tests/0100_selections.yml deleted file mode 100644 index e132af2bf..000000000 --- a/roles/alternatives/tests/0100_selections.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_alternatives_selections: - - selection: editor - path: /bin/ed - pre_tasks: - - apt: - name: - - nano - - ed - install_recommends: false - - alternatives: - name: editor - path: /bin/nano - roles: - - manala.alternatives - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/ansible/.gitignore b/roles/ansible/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/ansible/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/ansible/.manala/make/Makefile b/roles/ansible/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/ansible/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/ansible/.manala/make/Makefile.docker b/roles/ansible/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/ansible/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/ansible/.manala/make/Makefile.host b/roles/ansible/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/ansible/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/ansible/.manala/make/Makefile.manala b/roles/ansible/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/ansible/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/ansible/.manala/make/Makefile.travis b/roles/ansible/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/ansible/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/ansible/.manala/make/gmsl/__gmsl b/roles/ansible/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/ansible/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/ansible/.manala/make/gmsl/gmsl b/roles/ansible/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/ansible/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/ansible/.travis.yml b/roles/ansible/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/ansible/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/ansible/CHANGELOG.md b/roles/ansible/CHANGELOG.md deleted file mode 100644 index 6b5147eac..000000000 --- a/roles/ansible/CHANGELOG.md +++ /dev/null @@ -1,64 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.3] - 2020-08-28 -### Changed -- Explicit file permissions - -## [2.0.2] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.1] - 2019-11-29 -### Changed -- Update 'lookup' to use 'query' -- Minimum required version of ansible up to 2.5.0 - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.7] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.6] - 2018-11-15 -### Changed -- Update base config template for ansible 2.6.5 - -## [1.0.5] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.4] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Update base config template for ansible 2.5.0 -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.3] - 2018-03-14 -### Changed -- Update base config template - -## [1.0.2] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.1] - 2017-11-09 -### Added -- Handle hosts file -- Handle config -- Handle host_vars files -- Handle group_vars files - -## [1.0.0] - 2017-05-29 -### Added -- Handle installation diff --git a/roles/ansible/Makefile b/roles/ansible/Makefile deleted file mode 100644 index d182867c8..000000000 --- a/roles/ansible/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.ansible -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/ansible/README.md b/roles/ansible/README.md index 45ece0e04..72c6bc117 100644 --- a/roles/ansible/README.md +++ b/roles/ansible/README.md @@ -1,24 +1,12 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Ansible [![Build Status](https://travis-ci.org/manala/ansible-role-ansible.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ansible) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Ansible This role will deal with the setup and the config of [Ansible](https://www.ansible.com/). -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements -This role is made to work with the __manala__ ansible debian package, available on the __manala__ debian repository. Please use the [**manala.apt**](https://galaxy.ansible.com/manala/apt/) role to handle it properly. +This role is made to work with the __manala__ ansible debian package, available on the __manala__ debian repository. Please use the [**manala.roles.apt**](../apt/) role to handle it properly. ```yaml manala_apt_preferences: @@ -27,82 +15,45 @@ manala_apt_preferences: ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.ansible -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.ansible -``` - -## Role Handlers - -None +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -### Definition - -| Name | Default | Type | Description | -| ----------------------------------------- | ------------------------- | ------- | -------------------------------------- | -| `manala_ansible_install_packages` | ~ | Array | Dependency packages to install | -| `manala_ansible_install_packages_default` | ['ansible'] | Array | Default dependency packages to install | -| `manala_ansible_hosts_file` | '/etc/ansible/hosts' | String | Hosts file path | -| `manala_ansible_hosts_template` | 'hosts/empty.j2' | String | Default hosts template path | -| `manala_ansible_hosts` | [] | Array | Hosts | -| `manala_ansible_config_file` | 'config/_base.j2' | String | Configuration file path | -| `manala_ansible_config_template` | 'hosts/empty.j2' | String | Default configuration template path | -| `manala_ansible_config` | [] | Array | Configuration | -| `manala_ansible_host_vars_exclusive` | false | Boolean | Host vars exclusivity | -| `manala_ansible_host_vars_dir` | '/etc/ansible/host_vars' | String | Host vars dir path | -| `manala_ansible_host_vars_template` | 'host_vars/empty.j2' | String | Default host vars template path | -| `manala_ansible_host_vars` | [] | Array | Host vars | -| `manala_ansible_group_vars_exclusive` | false | Boolean | Group vars exclusivity | -| `manala_ansible_group_vars_dir` | '/etc/ansible/group_vars' | String | Group vars dir path | -| `manala_ansible_group_vars_template` | 'group_vars/empty.j2' | String | Default group vars template path | -| `manala_ansible_group_vars` | [] | Array | Group vars | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example ```yaml -manala_ansible_hosts: - - foo: > - ansible_host=foo.com - ansible_user=foo - - bar: - - foo - - bar:vars: - - bar=baz - -manala_ansible_config: - - defaults: - - forks: 123 - - ask_sudo_pass: false - - module_set_locale: true +manala_ansible_hosts: | + foo ansible_host=foo.com ansible_user=foo + [bar] + foo + [bar:vars] + bar=baz + +manala_ansible_config: | + [defaults] + forks = 123 + ask_sudo_pass = False + module_set_locale =: True manala_ansible_host_vars_exclusive: true manala_ansible_host_vars: - file: foo.yml - vars: - - foo: ~ - - bar: bar - - baz: 123 + vars: | + foo: ~ + bar: bar + baz: 123 - file: bar.yml state: absent manala_ansible_group_vars_exclusive: true manala_ansible_group_vars: - file: foo.yml - vars: - - foo: ~ - - bar: bar - - baz: 123 + vars: | + foo: ~ + bar: bar + baz: 123 - file: bar.yml state: absent ``` @@ -111,13 +62,16 @@ manala_ansible_group_vars: ```yaml - hosts: all - roles: - - role: manala.ansible + tasks: + - import_role: + name: manala.roles.ansible ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/ansible/defaults/main.yml b/roles/ansible/defaults/main.yml index f78ea3dd0..d6ee2443f 100644 --- a/roles/ansible/defaults/main.yml +++ b/roles/ansible/defaults/main.yml @@ -8,21 +8,21 @@ manala_ansible_install_packages_default: # Hosts manala_ansible_hosts_file: /etc/ansible/hosts manala_ansible_hosts_template: ~ -manala_ansible_hosts: [] +manala_ansible_hosts: ~ # Config manala_ansible_config_file: /etc/ansible/ansible.cfg manala_ansible_config_template: ~ -manala_ansible_config: [] +manala_ansible_config: ~ # Host vars manala_ansible_host_vars_exclusive: false manala_ansible_host_vars_dir: /etc/ansible/host_vars -manala_ansible_host_vars_template: ~ +manala_ansible_host_vars_defaults: {} manala_ansible_host_vars: [] # Group vars manala_ansible_group_vars_exclusive: false manala_ansible_group_vars_dir: /etc/ansible/group_vars -manala_ansible_group_vars_template: ~ +manala_ansible_group_vars_defaults: {} manala_ansible_group_vars: [] diff --git a/roles/ansible/lookup_plugins/.gitignore b/roles/ansible/lookup_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/ansible/lookup_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/ansible/lookup_plugins/manala_ansible_files.py b/roles/ansible/lookup_plugins/manala_ansible_files.py deleted file mode 100644 index 058f365d1..000000000 --- a/roles/ansible/lookup_plugins/manala_ansible_files.py +++ /dev/null @@ -1,70 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.errors import AnsibleError - -import os - -class LookupModule(LookupBase): - - def run(self, terms, variables=None, **kwargs): - - results = [] - - wantstate = kwargs.pop('wantstate', None) - - files = self._flatten(terms[0]) - filesExclusive = self._flatten(terms[1]) - filesDir = terms[2] - - itemDefault = { - 'state': 'present' - } - - # Mark exclusive files as absent - for file in filesExclusive: - item = itemDefault.copy() - item.update({ - 'file': file['path'], - 'state': 'absent' - }) - results.append(item) - - for file in files: - - items = [] - - # Must be a dict - if not isinstance(file, dict): - raise AnsibleError('Expect a dict') - - # Check index key - if 'file' not in file: - raise AnsibleError('Expect "file" key') - - item = itemDefault.copy() - item.update(file) - item.update({ - 'file': os.path.join(filesDir, item['file']) - }) - - items.append(item) - - # Merge by index key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['file'] == item['file']: - results[i] = item - itemFound = True - break - - if not itemFound: - results.append(item) - - # Filter by state - if wantstate: - results = [result for result in results if result.get('state') == wantstate] - - return results diff --git a/roles/ansible/meta/main.yml b/roles/ansible/meta/main.yml index 12842e98c..c4780f5d0 100644 --- a/roles/ansible/meta/main.yml +++ b/roles/ansible/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: ansible - author: Manala - company: Manala - description: Handle ansible - license: MIT - min_ansible_version: 2.5.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: ansible + author: Manala + company: Manala + description: Handle ansible + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - ansible diff --git a/roles/ansible/tasks/config.yml b/roles/ansible/tasks/config.yml index 84bcdfa24..70f855b53 100644 --- a/roles/ansible/tasks/config.yml +++ b/roles/ansible/tasks/config.yml @@ -2,9 +2,10 @@ - name: config > Template template: - src: "{{ manala_ansible_config_template|ternary(manala_ansible_config_template, 'config/_base.j2') }}" + src: "{{ manala_ansible_config_template|default('config/_default.j2', true) }}" dest: "{{ manala_ansible_config_file }}" owner: root group: root mode: "0644" - when: (manala_ansible_config_template is not none) or (manala_ansible_config|length) + when: manala_ansible_config_template + or manala_ansible_config diff --git a/roles/ansible/tasks/group_vars.yml b/roles/ansible/tasks/group_vars.yml index 39001a8a4..6ba97af08 100644 --- a/roles/ansible/tasks/group_vars.yml +++ b/roles/ansible/tasks/group_vars.yml @@ -12,36 +12,37 @@ - name: group_vars > Exclusive find: path: "{{ manala_ansible_group_vars_dir }}" + file_type: file + patterns: "*" changed_when: false register: __manala_ansible_group_vars_exclusive_find when: manala_ansible_group_vars_exclusive - name: group_vars > Templates presents template: - src: "{{ item.template|default(manala_ansible_group_vars_template|ternary(manala_ansible_group_vars_template, 'group_vars/empty.j2')) }}" + src: "{{ item.template }}" dest: "{{ item.file }}" owner: root group: root mode: "0644" loop: "{{ query( - 'manala_ansible_files', - manala_ansible_group_vars, - __manala_ansible_group_vars_exclusive_find.files|default([]), - manala_ansible_group_vars_dir, - wantstate='present' - ) - }}" + 'manala.roles.templates_exclusive', + manala_ansible_group_vars, + __manala_ansible_group_vars_exclusive_find.files|default([]), + manala_ansible_group_vars_dir, + manala_ansible_group_vars_defaults.template|default('group_vars/_default.j2', true), + wantstate='present' + ) }}" -# Ansible template module does not support "state" parameter (see: https://github.com/ansible/ansible/issues/29781) - name: group_vars > Files absents file: - path: "{{ item.file }}" + path: "{{ item.file }}" state: absent loop: "{{ query( - 'manala_ansible_files', - manala_ansible_group_vars, - __manala_ansible_group_vars_exclusive_find.files|default([]), - manala_ansible_group_vars_dir, - wantstate='absent' - ) - }}" + 'manala.roles.templates_exclusive', + manala_ansible_group_vars, + __manala_ansible_group_vars_exclusive_find.files|default([]), + manala_ansible_group_vars_dir, + manala_ansible_group_vars_defaults.template|default('group_vars/_default.j2', true), + wantstate='absent' + ) }}" diff --git a/roles/ansible/tasks/host_vars.yml b/roles/ansible/tasks/host_vars.yml index beb5d873d..b79962064 100644 --- a/roles/ansible/tasks/host_vars.yml +++ b/roles/ansible/tasks/host_vars.yml @@ -12,36 +12,37 @@ - name: host_vars > Exclusive find: path: "{{ manala_ansible_host_vars_dir }}" + file_type: file + patterns: "*" changed_when: false register: __manala_ansible_host_vars_exclusive_find when: manala_ansible_host_vars_exclusive - name: host_vars > Templates presents template: - src: "{{ item.template|default(manala_ansible_host_vars_template|ternary(manala_ansible_host_vars_template, 'host_vars/empty.j2')) }}" + src: "{{ item.template }}" dest: "{{ item.file }}" owner: root group: root mode: "0644" loop: "{{ query( - 'manala_ansible_files', - manala_ansible_host_vars, - __manala_ansible_host_vars_exclusive_find.files|default([]), - manala_ansible_host_vars_dir, - wantstate='present' - ) - }}" + 'manala.roles.templates_exclusive', + manala_ansible_host_vars, + __manala_ansible_host_vars_exclusive_find.files|default([]), + manala_ansible_host_vars_dir, + manala_ansible_host_vars_defaults.template|default('host_vars/_default.j2', true), + wantstate='present' + ) }}" -# Ansible template module does not support "state" parameter (see: https://github.com/ansible/ansible/issues/29781) - name: host_vars > Files absents file: path: "{{ item.file }}" state: absent loop: "{{ query( - 'manala_ansible_files', - manala_ansible_host_vars, - __manala_ansible_host_vars_exclusive_find.files|default([]), - manala_ansible_host_vars_dir, - wantstate='absent' - ) - }}" + 'manala.roles.templates_exclusive', + manala_ansible_host_vars, + __manala_ansible_host_vars_exclusive_find.files|default([]), + manala_ansible_host_vars_dir, + manala_ansible_host_vars_defaults.template|default('host_vars/_default.j2', true), + wantstate='absent' + ) }}" diff --git a/roles/ansible/tasks/hosts.yml b/roles/ansible/tasks/hosts.yml index caecc874c..c55d1d254 100644 --- a/roles/ansible/tasks/hosts.yml +++ b/roles/ansible/tasks/hosts.yml @@ -2,9 +2,10 @@ - name: hosts > Template template: - src: "{{ manala_ansible_hosts_template|ternary(manala_ansible_hosts_template, 'hosts/empty.j2') }}" + src: "{{ manala_ansible_hosts_template|default('hosts/_default.j2', true) }}" dest: "{{ manala_ansible_hosts_file }}" owner: root group: root mode: "0644" - when: (manala_ansible_hosts_template is not none) or (manala_ansible_hosts|length) + when: manala_ansible_hosts_template + or manala_ansible_hosts diff --git a/roles/ansible/tasks/install.yml b/roles/ansible/tasks/install.yml index d523ad495..d59e67e56 100644 --- a/roles/ansible/tasks/install.yml +++ b/roles/ansible/tasks/install.yml @@ -2,7 +2,9 @@ - name: install > Packages apt: - name: "{{ manala_ansible_install_packages|default(manala_ansible_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_ansible_install_packages|default(manala_ansible_install_packages_default, True) }}" diff --git a/roles/ansible/templates/config/_base.j2 b/roles/ansible/templates/config/_base.j2 deleted file mode 100644 index a472d1df1..000000000 --- a/roles/ansible/templates/config/_base.j2 +++ /dev/null @@ -1,670 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_ansible_config -%} - -{% set config_defaults = [] -%} -{% set config_inventory = [] -%} -{% set config_privilege_escalation = [] -%} -{% set config_paramiko_connection = [] -%} -{% set config_ssh_connection = [] -%} -{% set config_persistent_connection = [] -%} -{% set config_accelerate = [] -%} -{% set config_selinux = [] -%} -{% set config_colors = [] -%} -{% set config_diff = [] -%} - -{%- for configs in config -%} - {%- for config_name, config_parameters in configs.items() -%} - {%- if config_name == 'defaults' -%} - {%- if config_defaults.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'inventory' -%} - {%- if config_inventory.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'privilege_escalation' -%} - {%- if config_privilege_escalation.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'paramiko_connection' -%} - {%- if config_paramiko_connection.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'ssh_connection' -%} - {%- if config_ssh_connection.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'persistent_connection' -%} - {%- if config_persistent_connection.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'accelerate' -%} - {%- if config_accelerate.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'selinux' -%} - {%- if config_selinux.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'colors' -%} - {%- if config_colors.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'diff' -%} - {%- if config_diff.extend(config_parameters) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} -{%- endfor -%} - -# config file for ansible -- https://ansible.com/ -# =============================================== - -# nearly all parameters can be overridden in ansible-playbook -# or with command line flags. ansible will read ANSIBLE_CONFIG, -# ansible.cfg in the current working directory, .ansible.cfg in -# the home directory or /etc/ansible/ansible.cfg, whichever it -# finds first - -[defaults] - -# some basic default values... - -{{ macros.config_row(config_defaults, 'inventory', '#inventory = /etc/ansible/hosts', 0, true) }} -{{ macros.config_row(config_defaults, 'library', '#library = /usr/share/my_modules/', 0, true) }} -{{ macros.config_row(config_defaults, 'module_utils', '#module_utils = /usr/share/my_module_utils/', 0, true) }} -{{ macros.config_row(config_defaults, 'remote_tmp', '#remote_tmp = ~/.ansible/tmp', 0, true) }} -{{ macros.config_row(config_defaults, 'local_tmp', '#local_tmp = ~/.ansible/tmp', 0, true) }} -{{ macros.config_row(config_defaults, 'plugin_filters_cfg', '#plugin_filters_cfg = /etc/ansible/plugin_filters.yml', 0, true) }} -{{ macros.config_row(config_defaults, 'forks', '#forks = 5', 0, true) }} -{{ macros.config_row(config_defaults, 'poll_interval', '#poll_interval = 15', 0, true) }} -{{ macros.config_row(config_defaults, 'sudo_user', '#sudo_user = root', 0, true) }} -{{ macros.config_row(config_defaults, 'ask_sudo_pass', '#ask_sudo_pass = True', 0, true) }} -{{ macros.config_row(config_defaults, 'ask_pass', '#ask_pass = True', 0, true) }} -{{ macros.config_row(config_defaults, 'transport', '#transport = smart', 0, true) }} -{{ macros.config_row(config_defaults, 'remote_port', '#remote_port = 22', 0, true) }} -{{ macros.config_row(config_defaults, 'module_lang', '#module_lang = C', 0, true) }} -{{ macros.config_row(config_defaults, 'module_set_locale', '#module_set_locale = False', 0, true) }} - -# plays will gather facts by default, which contain information about -# the remote system. -# -# smart - gather by default, but don't regather if already gathered -# implicit - gather by default, turn off with gather_facts: False -# explicit - do not gather by default, must say gather_facts: True -{{ macros.config_row(config_defaults, 'gathering', '#gathering = implicit', 0, true) }} - -# This only affects the gathering done by a play's gather_facts directive, -# by default gathering retrieves all facts subsets -# all - gather all subsets -# network - gather min and network facts -# hardware - gather hardware facts (longest facts to retrieve) -# virtual - gather min and virtual facts -# facter - import facts from facter -# ohai - import facts from ohai -# You can combine them using comma (ex: network,virtual) -# You can negate them using ! (ex: !hardware,!facter,!ohai) -# A minimal set of facts is always gathered. -{{ macros.config_row(config_defaults, 'gather_subset', '#gather_subset = all', 0, true) }} - -# some hardware related facts are collected -# with a maximum timeout of 10 seconds. This -# option lets you increase or decrease that -# timeout to something more suitable for the -# environment. -{{ macros.config_row(config_defaults, 'gather_timeout', '# gather_timeout = 10', 0, true) }} - -# additional paths to search for roles in, colon separated -{{ macros.config_row(config_defaults, 'roles_path', '#roles_path = /etc/ansible/roles', 0, true) }} - -# uncomment this to disable SSH key host checking -{{ macros.config_row(config_defaults, 'host_key_checking', '#host_key_checking = False', 0, true) }} - -# change the default callback, you can only have one 'stdout' type enabled at a time. -{{ macros.config_row(config_defaults, 'stdout_callback', '#stdout_callback = skippy', 0, true) }} - - -## Ansible ships with some plugins that require whitelisting, -## this is done to avoid running all of a type by default. -## These setting lists those that you want enabled for your system. -## Custom plugins should not need this unless plugin author specifies it. - -# enable callback plugins, they can output to stdout but cannot be 'stdout' type. -{{ macros.config_row(config_defaults, 'callback_whitelist', '#callback_whitelist = timer, mail', 0, true) }} - -# Determine whether includes in tasks and handlers are "static" by -# default. As of 2.0, includes are dynamic by default. Setting these -# values to True will make includes behave more like they did in the -# 1.x versions. -{{ macros.config_row(config_defaults, 'task_includes_static', '#task_includes_static = False', 0, true) }} -{{ macros.config_row(config_defaults, 'handler_includes_static', '#handler_includes_static = False', 0, true) }} - -# Controls if a missing handler for a notification event is an error or a warning -{{ macros.config_row(config_defaults, 'error_on_missing_handler', '#error_on_missing_handler = True', 0, true) }} - -# change this for alternative sudo implementations -{{ macros.config_row(config_defaults, 'sudo_exe', '#sudo_exe = sudo', 0, true) }} - -# What flags to pass to sudo -# WARNING: leaving out the defaults might create unexpected behaviours -{{ macros.config_row(config_defaults, 'sudo_flags', '#sudo_flags = -H -S -n', 0, true) }} - -# SSH timeout -{{ macros.config_row(config_defaults, 'timeout', '#timeout = 10', 0, true) }} - -# default user to use for playbooks if user is not specified -# (/usr/bin/ansible will use current user as default) -{{ macros.config_row(config_defaults, 'remote_user', '#remote_user = root', 0, true) }} - -# logging is off by default unless this path is defined -# if so defined, consider logrotate -{{ macros.config_row(config_defaults, 'log_path', '#log_path = /var/log/ansible.log', 0, true) }} - -# default module name for /usr/bin/ansible -{{ macros.config_row(config_defaults, 'module_name', '#module_name = command', 0, true) }} - -# use this shell for commands executed under sudo -# you may need to change this to bin/bash in rare instances -# if sudo is constrained -{{ macros.config_row(config_defaults, 'executable', '#executable = /bin/sh', 0, true) }} - -# if inventory variables overlap, does the higher precedence one win -# or are hash values merged together? The default is 'replace' but -# this can also be set to 'merge'. -{{ macros.config_row(config_defaults, 'hash_behaviour', '#hash_behaviour = replace', 0, true) }} - -# by default, variables from roles will be visible in the global variable -# scope. To prevent this, the following option can be enabled, and only -# tasks and handlers within the role will see the variables there -{{ macros.config_row(config_defaults, 'private_role_vars', '#private_role_vars = yes', 0, true) }} - -# list any Jinja2 extensions to enable here: -{{ macros.config_row(config_defaults, 'jinja2_extensions', '#jinja2_extensions = jinja2.ext.do,jinja2.ext.i18n', 0, true) }} - -# if set, always use this private key file for authentication, same as -# if passing --private-key to ansible or ansible-playbook -{{ macros.config_row(config_defaults, 'private_key_file', '#private_key_file = /path/to/file', 0, true) }} - -# If set, configures the path to the Vault password file as an alternative to -# specifying --vault-password-file on the command line. -{{ macros.config_row(config_defaults, 'vault_password_file', '#vault_password_file = /path/to/vault_password_file', 0, true) }} - -# format of string {{ '{{' }} ansible_managed {{ '}}' }} available within Jinja2 -# templates indicates to users editing templates files will be replaced. -# replacing {file}, {host} and {uid} and strftime codes with proper values. -#ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host} -# {file}, {host}, {uid}, and the timestamp can all interfere with idempotence -# in some situations so the default is a static string: -{{ macros.config_row(config_defaults, 'ansible_managed', '#ansible_managed = Ansible managed', 0, true) }} - -# by default, ansible-playbook will display "Skipping [host]" if it determines a task -# should not be run on a host. Set this to "False" if you don't want to see these "Skipping" -# messages. NOTE: the task header will still be shown regardless of whether or not the -# task is skipped. -{{ macros.config_row(config_defaults, 'display_skipped_hosts', '#display_skipped_hosts = True', 0, true) }} - -# by default, if a task in a playbook does not include a name: field then -# ansible-playbook will construct a header that includes the task's action but -# not the task's args. This is a security feature because ansible cannot know -# if the *module* considers an argument to be no_log at the time that the -# header is printed. If your environment doesn't have a problem securing -# stdout from ansible-playbook (or you have manually specified no_log in your -# playbook on all of the tasks where you have secret information) then you can -# safely set this to True to get more informative messages. -{{ macros.config_row(config_defaults, 'display_args_to_stdout', '#display_args_to_stdout = False', 0, true) }} - -# by default (as of 1.3), Ansible will raise errors when attempting to dereference -# Jinja2 variables that are not set in templates or action lines. Uncomment this line -# to revert the behavior to pre-1.3. -{{ macros.config_row(config_defaults, 'error_on_undefined_vars', '#error_on_undefined_vars = False', 0, true) }} - -# by default (as of 1.6), Ansible may display warnings based on the configuration of the -# system running ansible itself. This may include warnings about 3rd party packages or -# other conditions that should be resolved if possible. -# to disable these warnings, set the following value to False: -{{ macros.config_row(config_defaults, 'system_warnings', '#system_warnings = True', 0, true) }} - -# by default (as of 1.4), Ansible may display deprecation warnings for language -# features that should no longer be used and will be removed in future versions. -# to disable these warnings, set the following value to False: -{{ macros.config_row(config_defaults, 'deprecation_warnings', '#deprecation_warnings = True', 0, true) }} - -# (as of 1.8), Ansible can optionally warn when usage of the shell and -# command module appear to be simplified by using a default Ansible module -# instead. These warnings can be silenced by adjusting the following -# setting or adding warn=yes or warn=no to the end of the command line -# parameter string. This will for example suggest using the git module -# instead of shelling out to the git command. -{{ macros.config_row(config_defaults, 'command_warnings', '# command_warnings = False', 0, true) }} - - -# set plugin path directories here, separate with colons -{{ macros.config_row(config_defaults, 'action_plugins', '#action_plugins = /usr/share/ansible/plugins/action', 0, true) }} -{{ macros.config_row(config_defaults, 'cache_plugins', '#cache_plugins = /usr/share/ansible/plugins/cache', 0, true) }} -{{ macros.config_row(config_defaults, 'callback_plugins', '#callback_plugins = /usr/share/ansible/plugins/callback', 0, true) }} -{{ macros.config_row(config_defaults, 'connection_plugins', '#connection_plugins = /usr/share/ansible/plugins/connection', 0, true) }} -{{ macros.config_row(config_defaults, 'lookup_plugins', '#lookup_plugins = /usr/share/ansible/plugins/lookup', 0, true) }} -{{ macros.config_row(config_defaults, 'inventory_plugins', '#inventory_plugins = /usr/share/ansible/plugins/inventory', 0, true) }} -{{ macros.config_row(config_defaults, 'vars_plugins', '#vars_plugins = /usr/share/ansible/plugins/vars', 0, true) }} -{{ macros.config_row(config_defaults, 'filter_plugins', '#filter_plugins = /usr/share/ansible/plugins/filter', 0, true) }} -{{ macros.config_row(config_defaults, 'test_plugins', '#test_plugins = /usr/share/ansible/plugins/test', 0, true) }} -{{ macros.config_row(config_defaults, 'terminal_plugins', '#terminal_plugins = /usr/share/ansible/plugins/terminal', 0, true) }} -{{ macros.config_row(config_defaults, 'strategy_plugins', '#strategy_plugins = /usr/share/ansible/plugins/strategy', 0, true) }} - - -# by default, ansible will use the 'linear' strategy but you may want to try -# another one -{{ macros.config_row(config_defaults, 'strategy', '#strategy = free', 0, true) }} - -# by default callbacks are not loaded for /bin/ansible, enable this if you -# want, for example, a notification or logging callback to also apply to -# /bin/ansible runs -{{ macros.config_row(config_defaults, 'bin_ansible_callbacks', '#bin_ansible_callbacks = False', 0, true) }} - - -# don't like cows? that's unfortunate. -# set to 1 if you don't want cowsay support or export ANSIBLE_NOCOWS=1 -{{ macros.config_row(config_defaults, 'nocows', '#nocows = 1', 0, true) }} - -# set which cowsay stencil you'd like to use by default. When set to 'random', -# a random stencil will be selected for each task. The selection will be filtered -# against the `cow_whitelist` option below. -#cow_selection = default -{{ macros.config_row(config_defaults, 'cow_selection', '#cow_selection = random', 0, true) }} - -# when using the 'random' option for cowsay, stencils will be restricted to this list. -# it should be formatted as a comma-separated list with no spaces between names. -# NOTE: line continuations here are for formatting purposes only, as the INI parser -# in python does not support them. -{{ macros.config_row(config_defaults, 'cow_whitelist', '#cow_whitelist=bud-frogs,bunny,cheese,daemon,default,dragon,elephant-in-snake,elephant,eyes,\\ -# hellokitty,kitty,luke-koala,meow,milk,moofasa,moose,ren,sheep,small,stegosaurus,\\ -# stimpy,supermilker,three-eyes,turkey,turtle,tux,udder,vader-koala,vader,www', 0, true) }} - -# don't like colors either? -# set to 1 if you don't want colors, or export ANSIBLE_NOCOLOR=1 -{{ macros.config_row(config_defaults, 'nocolor', '#nocolor = 1', 0, true) }} - -# if set to a persistent type (not 'memory', for example 'redis') fact values -# from previous runs in Ansible will be stored. This may be useful when -# wanting to use, for example, IP information from one group of servers -# without having to talk to them in the same playbook run to get their -# current IP information. -{{ macros.config_row(config_defaults, 'fact_caching', '#fact_caching = memory', 0, true) }} - - -# retry files -# When a playbook fails by default a .retry file will be created in ~/ -# You can disable this feature by setting retry_files_enabled to False -# and you can change the location of the files by setting retry_files_save_path - -{{ macros.config_row(config_defaults, 'retry_files_enabled', '#retry_files_enabled = False', 0, true) }} -{{ macros.config_row(config_defaults, 'retry_files_save_path', '#retry_files_save_path = ~/.ansible-retry', 0, true) }} - -# squash actions -# Ansible can optimise actions that call modules with list parameters -# when looping. Instead of calling the module once per with_ item, the -# module is called once with all items at once. Currently this only works -# under limited circumstances, and only with parameters named 'name'. -{{ macros.config_row(config_defaults, 'squash_actions', '#squash_actions = apk,apt,dnf,homebrew,pacman,pkgng,yum,zypper', 0, true) }} - -# prevents logging of task data, off by default -{{ macros.config_row(config_defaults, 'no_log', '#no_log = False', 0, true) }} - -# prevents logging of tasks, but only on the targets, data is still logged on the master/controller -{{ macros.config_row(config_defaults, 'no_target_syslog', '#no_target_syslog = False', 0, true) }} - -# controls whether Ansible will raise an error or warning if a task has no -# choice but to create world readable temporary files to execute a module on -# the remote machine. This option is False by default for security. Users may -# turn this on to have behaviour more like Ansible prior to 2.1.x. See -# https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user -# for more secure ways to fix this than enabling this option. -{{ macros.config_row(config_defaults, 'allow_world_readable_tmpfiles', '#allow_world_readable_tmpfiles = False', 0, true) }} - -# controls the compression level of variables sent to -# worker processes. At the default of 0, no compression -# is used. This value must be an integer from 0 to 9. -{{ macros.config_row(config_defaults, 'var_compression_level', '#var_compression_level = 9', 0, true) }} - -# controls what compression method is used for new-style ansible modules when -# they are sent to the remote system. The compression types depend on having -# support compiled into both the controller's python and the client's python. -# The names should match with the python Zipfile compression types: -# * ZIP_STORED (no compression. available everywhere) -# * ZIP_DEFLATED (uses zlib, the default) -# These values may be set per host via the ansible_module_compression inventory -# variable -{{ macros.config_row(config_defaults, 'module_compression', '#module_compression = \'ZIP_DEFLATED\'', 0, true) }} - -# This controls the cutoff point (in bytes) on --diff for files -# set to 0 for unlimited (RAM may suffer!). -{{ macros.config_row(config_defaults, 'max_diff_size', '#max_diff_size = 1048576', 0, true) }} - -# This controls how ansible handles multiple --tags and --skip-tags arguments -# on the CLI. If this is True then multiple arguments are merged together. If -# it is False, then the last specified argument is used and the others are ignored. -# This option will be removed in 2.8. -{{ macros.config_row(config_defaults, 'merge_multiple_cli_flags', '#merge_multiple_cli_flags = True', 0, true) }} - -# Controls showing custom stats at the end, off by default -{{ macros.config_row(config_defaults, 'show_custom_stats', '#show_custom_stats = True', 0, true) }} - -# Controls which files to ignore when using a directory as inventory with -# possibly multiple sources (both static and dynamic) -{{ macros.config_row(config_defaults, 'inventory_ignore_extensions', '#inventory_ignore_extensions = ~, .orig, .bak, .ini, .cfg, .retry, .pyc, .pyo', 0, true) }} - -# This family of modules use an alternative execution path optimized for network appliances -# only update this setting if you know how this works, otherwise it can break module execution -{{ macros.config_row(config_defaults, 'network_group_modules', '#network_group_modules=eos, nxos, ios, iosxr, junos, vyos', 0, true) }} - -# When enabled, this option allows lookups (via variables like {{ '{{' }}lookup('foo'){{ '}}' }} or when used as -# a loop with `with_foo`) to return data that is not marked "unsafe". This means the data may contain -# jinja2 templating language which will be run through the templating engine. -# ENABLING THIS COULD BE A SECURITY RISK -{{ macros.config_row(config_defaults, 'allow_unsafe_lookups', '#allow_unsafe_lookups = False', 0, true) }} - -# set default errors for all plays -{{ macros.config_row(config_defaults, 'any_errors_fatal', '#any_errors_fatal = False', 0, true) }} -{{ macros.config(config_defaults, [ - 'inventory', - 'library', - 'module_utils', - 'remote_tmp', - 'local_tmp', - 'forks', - 'plugin_filters_cfg', - 'poll_interval', - 'sudo_user', - 'ask_sudo_pass', - 'ask_pass', - 'transport', - 'remote_port', - 'module_lang', - 'module_set_locale', - 'gathering', - 'gather_subset', - 'gather_timeout', - 'roles_path', - 'host_key_checking', - 'stdout_callback', - 'callback_whitelist', - 'task_includes_static', - 'handler_includes_static', - 'error_on_missing_handler', - 'sudo_exe', - 'sudo_flags', - 'timeout', - 'remote_user', - 'log_path', - 'module_name', - 'executable', - 'hash_behaviour', - 'private_role_vars', - 'jinja2_extensions', - 'private_key_file', - 'vault_password_file', - 'ansible_managed', - 'display_skipped_hosts', - 'display_args_to_stdout', - 'error_on_undefined_vars', - 'system_warnings', - 'deprecation_warnings', - 'command_warnings', - 'action_plugins', - 'cache_plugins', - 'callback_plugins', - 'connection_plugins', - 'lookup_plugins', - 'inventory_plugins', - 'vars_plugins', - 'filter_plugins', - 'test_plugins', - 'terminal_plugins', - 'strategy_plugins', - 'strategy', - 'bin_ansible_callbacks', - 'nocows', - 'cow_selection', - 'cow_whitelist', - 'nocolor', - 'fact_caching', - 'retry_files_enabled', - 'retry_files_save_path', - 'squash_actions', - 'no_log', - 'no_target_syslog', - 'allow_world_readable_tmpfiles', - 'var_compression_level', - 'module_compression', - 'max_diff_size', - 'merge_multiple_cli_flags', - 'show_custom_stats', - 'inventory_ignore_extensions', - 'network_group_modules', - 'allow_unsafe_lookups', - 'any_errors_fatal' -]) }} - -[inventory] -# enable inventory plugins, default: 'host_list', 'script', 'yaml', 'ini' -{{ macros.config_row(config_inventory, 'enable_plugins', '#enable_plugins = host_list, virtualbox, yaml, constructed', 0, true) }} - -# ignore these extensions when parsing a directory as inventory source -{{ macros.config_row(config_inventory, 'ignore_extensions', '#ignore_extensions = .pyc, .pyo, .swp, .bak, ~, .rpm, .md, .txt, ~, .orig, .ini, .cfg, .retry', 0, true) }} - -# ignore files matching these patterns when parsing a directory as inventory source -{{ macros.config_row(config_inventory, 'ignore_patterns', '#ignore_patterns=', 0, true) }} - -# If 'true' unparsed inventory sources become fatal errors, they are warnings otherwise. -{{ macros.config_row(config_inventory, 'unparsed_is_failed', '#unparsed_is_failed=False', 0, true) }} -{{ macros.config(config_inventory, [ - 'enable_plugins', - 'ignore_extensions', - 'ignore_patterns', - 'unparsed_is_failed' -]) }} - -[privilege_escalation] -{{ macros.config_row(config_privilege_escalation, 'become', '#become=True', 0, true) }} -{{ macros.config_row(config_privilege_escalation, 'become_method', '#become_method=sudo', 0, true) }} -{{ macros.config_row(config_privilege_escalation, 'become_user', '#become_user=root', 0, true) }} -{{ macros.config_row(config_privilege_escalation, 'become_ask_pass', '#become_ask_pass=False', 0, true) }} -{{ macros.config(config_privilege_escalation, [ - 'become', - 'become_method', - 'become_user', - 'become_ask_pass' -]) }} -[paramiko_connection] - -# uncomment this line to cause the paramiko connection plugin to not record new host -# keys encountered. Increases performance on new host additions. Setting works independently of the -# host key checking setting above. -{{ macros.config_row(config_paramiko_connection, 'record_host_keys', '#record_host_keys=False', 0, true) }} - -# by default, Ansible requests a pseudo-terminal for commands executed under sudo. Uncomment this -# line to disable this behaviour. -{{ macros.config_row(config_paramiko_connection, 'pty', '#pty=False', 0, true) }} - -# paramiko will default to looking for SSH keys initially when trying to -# authenticate to remote devices. This is a problem for some network devices -# that close the connection after a key failure. Uncomment this line to -# disable the Paramiko look for keys function -{{ macros.config_row(config_paramiko_connection, 'look_for_keys', '#look_for_keys = False', 0, true) }} - -# When using persistent connections with Paramiko, the connection runs in a -# background process. If the host doesn't already have a valid SSH key, by -# default Ansible will prompt to add the host key. This will cause connections -# running in background processes to fail. Uncomment this line to have -# Paramiko automatically add host keys. -{{ macros.config_row(config_paramiko_connection, 'host_key_auto_add', '#host_key_auto_add = True', 0, true) }} -{{ macros.config(config_paramiko_connection, [ - 'record_host_keys', - 'pty', - 'look_for_keys', - 'host_key_auto_add' -]) }} -[ssh_connection] - -# ssh arguments to use -# Leaving off ControlPersist will result in poor performance, so use -# paramiko on older platforms rather than removing it, -C controls compression use -{{ macros.config_row(config_ssh_connection, 'ssh_args', '#ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s', 0, true) }} - -# The base directory for the ControlPath sockets. -# This is the "%(directory)s" in the control_path option -# -# Example: -# control_path_dir = /tmp/.ansible/cp -{{ macros.config_row(config_ssh_connection, 'control_path_dir', '#control_path_dir = ~/.ansible/cp', 0, true) }} - -# The path to use for the ControlPath sockets. This defaults to a hashed string of the hostname, -# port and username (empty string in the config). The hash mitigates a common problem users -# found with long hostames and the conventional %(directory)s/ansible-ssh-%%h-%%p-%%r format. -# In those cases, a "too long for Unix domain socket" ssh error would occur. -# -# Example: -# control_path = %(directory)s/%%h-%%r -{{ macros.config_row(config_ssh_connection, 'control_path', '#control_path =', 0, true) }} - -# Enabling pipelining reduces the number of SSH operations required to -# execute a module on the remote server. This can result in a significant -# performance improvement when enabled, however when using "sudo:" you must -# first disable 'requiretty' in /etc/sudoers -# -# By default, this option is disabled to preserve compatibility with -# sudoers configurations that have requiretty (the default on many distros). -# -{{ macros.config_row(config_ssh_connection, 'pipelining', '#pipelining = False', 0, true) }} - -# Control the mechanism for transferring files (old) -# * smart = try sftp and then try scp [default] -# * True = use scp only -# * False = use sftp only -{{ macros.config_row(config_ssh_connection, 'scp_if_ssh', '#scp_if_ssh = smart', 0, true) }} - -# Control the mechanism for transferring files (new) -# If set, this will override the scp_if_ssh option -# * sftp = use sftp to transfer files -# * scp = use scp to transfer files -# * piped = use 'dd' over SSH to transfer files -# * smart = try sftp, scp, and piped, in that order [default] -{{ macros.config_row(config_ssh_connection, 'transfer_method', '#transfer_method = smart', 0, true) }} - -# if False, sftp will not use batch mode to transfer files. This may cause some -# types of file transfer failures impossible to catch however, and should -# only be disabled if your sftp version has problems with batch mode -{{ macros.config_row(config_ssh_connection, 'sftp_batch_mode', '#sftp_batch_mode = False', 0, true) }} - -# The -tt argument is passed to ssh when pipelining is not enabled because sudo -# requires a tty by default. -{{ macros.config_row(config_ssh_connection, 'use_tty', '#use_tty = True', 0, true) }} - -# Number of times to retry an SSH connection to a host, in case of UNREACHABLE. -# For each retry attempt, there is an exponential backoff, -# so after the first attempt there is 1s wait, then 2s, 4s etc. up to 30s (max). -{{ macros.config_row(config_ssh_connection, 'retries', '#retries = 3', 0, true) }} - -{{ macros.config(config_ssh_connection, [ - 'ssh_args', - 'control_path_dir', - 'control_path', - 'pipelining', - 'scp_if_ssh', - 'transfer_method', - 'sftp_batch_mode', - 'use_tty', - 'retries' -]) }} -[persistent_connection] - -# Configures the persistent connection timeout value in seconds. This value is -# how long the persistent connection will remain idle before it is destroyed. -# If the connection doesn't receive a request before the timeout value -# expires, the connection is shutdown. The default value is 30 seconds. -{{ macros.config_row(config_persistent_connection, 'connect_timeout', '#connect_timeout = 30', 0, true) }} - -# Configures the persistent connection retry timeout. This value configures the -# the retry timeout that ansible-connection will wait to connect -# to the local domain socket. This value must be larger than the -# ssh timeout (timeout) and less than persistent connection idle timeout (connect_timeout). -# The default value is 15 seconds. -{{ macros.config_row(config_persistent_connection, 'connect_retry_timeout', '#connect_retry_timeout = 15', 0, true) }} - -# The command timeout value defines the amount of time to wait for a command -# or RPC call before timing out. The value for the command timeout must -# be less than the value of the persistent connection idle timeout (connect_timeout) -# The default value is 10 second. -{{ macros.config_row(config_persistent_connection, 'command_timeout', '#command_timeout = 10', 0, true) }} -{{ macros.config(config_persistent_connection, [ - 'connect_timeout', - 'connect_retry_timeout', - 'command_timeout' -]) }} -[accelerate] -{{ macros.config_row(config_accelerate, 'accelerate_port', '#accelerate_port = 5099', 0, true) }} -{{ macros.config_row(config_accelerate, 'accelerate_timeout', '#accelerate_timeout = 30', 0, true) }} -{{ macros.config_row(config_accelerate, 'accelerate_connect_timeout', '#accelerate_connect_timeout = 5.0', 0, true) }} - -# The daemon timeout is measured in minutes. This time is measured -# from the last activity to the accelerate daemon. -{{ macros.config_row(config_accelerate, 'accelerate_daemon_timeout', '#accelerate_daemon_timeout = 30', 0, true) }} - -# If set to yes, accelerate_multi_key will allow multiple -# private keys to be uploaded to it, though each user must -# have access to the system via SSH to add a new key. The default -# is "no". -{{ macros.config_row(config_accelerate, 'accelerate_multi_key', '#accelerate_multi_key = yes', 0, true) }} -{{ macros.config(config_accelerate, [ - 'accelerate_port', - 'accelerate_timeout', - 'accelerate_connect_timeout', - 'accelerate_daemon_timeout', - 'accelerate_multi_key' -]) }} -[selinux] -# file systems that require special treatment when dealing with security context -# the default behaviour that copies the existing context or uses the user default -# needs to be changed to use the file system dependent context. -{{ macros.config_row(config_selinux, 'special_context_filesystems', '#special_context_filesystems=nfs,vboxsf,fuse,ramfs,9p', 0, true) }} - -# Set this to yes to allow libvirt_lxc connections to work without SELinux. -{{ macros.config_row(config_selinux, 'libvirt_lxc_noseclabel', '#libvirt_lxc_noseclabel = yes', 0, true) }} -{{ macros.config(config_selinux, [ - 'special_context_filesystems', - 'libvirt_lxc_noseclabel' -]) }} -[colors] -{{ macros.config_row(config_colors, 'highlight', '#highlight = white', 0, true) }} -{{ macros.config_row(config_colors, 'verbose', '#verbose = blue', 0, true) }} -{{ macros.config_row(config_colors, 'warn', '#warn = bright purple', 0, true) }} -{{ macros.config_row(config_colors, 'error', '#error = red', 0, true) }} -{{ macros.config_row(config_colors, 'debug', '#debug = dark gray', 0, true) }} -{{ macros.config_row(config_colors, 'deprecate', '#deprecate = purple', 0, true) }} -{{ macros.config_row(config_colors, 'skip', '#skip = cyan', 0, true) }} -{{ macros.config_row(config_colors, 'unreachable', '#unreachable = red', 0, true) }} -{{ macros.config_row(config_colors, 'ok', '#ok = green', 0, true) }} -{{ macros.config_row(config_colors, 'changed', '#changed = yellow', 0, true) }} -{{ macros.config_row(config_colors, 'diff_add', '#diff_add = green', 0, true) }} -{{ macros.config_row(config_colors, 'diff_remove', '#diff_remove = red', 0, true) }} -{{ macros.config_row(config_colors, 'diff_lines', '#diff_lines = cyan', 0, true) }} -{{ macros.config(config_colors, [ - 'highlight', - 'verbose', - 'warn', - 'error', - 'debug', - 'deprecate', - 'skip', - 'unreachable', - 'ok', - 'changed', - 'diff_add', - 'diff_remove', - 'diff_lines' -]) }} - -[diff] -# Always print diff when running ( same as always running with -D/--diff ) -{{ macros.config_row(config_diff, 'always', '# always = no', 0, true) }} - -# Set how many context lines to show in diff -{{ macros.config_row(config_diff, 'context', '# context = 3', 0, true) }} -{{ macros.config(config_diff, [ - 'always', - 'context' -]) }} - -{{ macros.config(config, [ - 'defaults', - 'privilege_escalation', - 'paramiko_connection', - 'ssh_connection', - 'persistent_connection', - 'accelerate', - 'selinux', - 'colors', - 'diff' -]) }} diff --git a/roles/ansible/templates/config/_default.j2 b/roles/ansible/templates/config/_default.j2 new file mode 100644 index 000000000..70986cc51 --- /dev/null +++ b/roles/ansible/templates/config/_default.j2 @@ -0,0 +1,3 @@ +{%- set config = manala_ansible_config -%} + +{{ config }} diff --git a/roles/ansible/templates/config/_macros.j2 b/roles/ansible/templates/config/_macros.j2 deleted file mode 100644 index a18a91c59..000000000 --- a/roles/ansible/templates/config/_macros.j2 +++ /dev/null @@ -1,64 +0,0 @@ -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }}{{ '\n' }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {%- if value is sequence and value is not string -%} - [{{ key }}]{{ '\n' }}{{ config(value, [], indent) }} - {%- else -%} - {{ _config_parameter_key(key)|indent(indent, true) }} = {{ _config_parameter_value(value) }} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - {{ key }} -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {%- if value is sameas none -%} - {%- elif value is sameas true -%} - True - {%- elif value is sameas false -%} - False - {%- elif value is string -%} - {{ value }} - {%- elif value is number -%} - {{ value }} - {%- endif -%} -{%- endmacro -%} diff --git a/roles/ansible/templates/group_vars/_default.j2 b/roles/ansible/templates/group_vars/_default.j2 new file mode 100644 index 000000000..b1c263034 --- /dev/null +++ b/roles/ansible/templates/group_vars/_default.j2 @@ -0,0 +1,3 @@ +{%- set vars = item.vars|default('') -%} + +{{ vars }} diff --git a/roles/ansible/templates/group_vars/_macros.j2 b/roles/ansible/templates/group_vars/_macros.j2 deleted file mode 100644 index 06f9b1f88..000000000 --- a/roles/ansible/templates/group_vars/_macros.j2 +++ /dev/null @@ -1,43 +0,0 @@ -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {{ {key: value}|to_nice_yaml() }} -{%- endmacro -%} diff --git a/roles/ansible/templates/group_vars/empty.j2 b/roles/ansible/templates/group_vars/empty.j2 deleted file mode 100644 index 71932e75f..000000000 --- a/roles/ansible/templates/group_vars/empty.j2 +++ /dev/null @@ -1,4 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} ---- - -{{ macros.config(item.vars|default([]), []) }} diff --git a/roles/ansible/templates/host_vars/_default.j2 b/roles/ansible/templates/host_vars/_default.j2 new file mode 100644 index 000000000..b1c263034 --- /dev/null +++ b/roles/ansible/templates/host_vars/_default.j2 @@ -0,0 +1,3 @@ +{%- set vars = item.vars|default('') -%} + +{{ vars }} diff --git a/roles/ansible/templates/host_vars/_macros.j2 b/roles/ansible/templates/host_vars/_macros.j2 deleted file mode 100644 index 06f9b1f88..000000000 --- a/roles/ansible/templates/host_vars/_macros.j2 +++ /dev/null @@ -1,43 +0,0 @@ -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {{ {key: value}|to_nice_yaml() }} -{%- endmacro -%} diff --git a/roles/ansible/templates/host_vars/empty.j2 b/roles/ansible/templates/host_vars/empty.j2 deleted file mode 100644 index 71932e75f..000000000 --- a/roles/ansible/templates/host_vars/empty.j2 +++ /dev/null @@ -1,4 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} ---- - -{{ macros.config(item.vars|default([]), []) }} diff --git a/roles/ansible/templates/hosts/_default.j2 b/roles/ansible/templates/hosts/_default.j2 new file mode 100644 index 000000000..ce6de1398 --- /dev/null +++ b/roles/ansible/templates/hosts/_default.j2 @@ -0,0 +1,3 @@ +{%- set config = manala_ansible_hosts -%} + +{{ config }} diff --git a/roles/ansible/templates/hosts/_macros.j2 b/roles/ansible/templates/hosts/_macros.j2 deleted file mode 100644 index 8403b7876..000000000 --- a/roles/ansible/templates/hosts/_macros.j2 +++ /dev/null @@ -1,67 +0,0 @@ -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {%- if value is sequence and value is not string -%} - {{ '\n' }}[{{ _config_parameter_key(key)|indent(indent, true) }}]{{ '\n' }} - {%- for data in value -%} - {{ _config_parameter_value(data) }}{{ '\n' }} - {%- endfor -%} - {%- else -%} - {{ _config_parameter_key(key)|indent(indent, true) }} {{ _config_parameter_value(value) }} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - {{ key }} -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {%- if value is sameas none -%} - {%- elif value is sameas true -%} - true - {%- elif value is sameas false -%} - false - {%- elif value is string -%} - {{ value }} - {%- elif value is number -%} - {{ value }} - {%- endif -%} -{%- endmacro -%} diff --git a/roles/ansible/templates/hosts/empty.j2 b/roles/ansible/templates/hosts/empty.j2 deleted file mode 100644 index 804b87f5d..000000000 --- a/roles/ansible/templates/hosts/empty.j2 +++ /dev/null @@ -1,5 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_ansible_hosts|default([]) -%} - -{{ macros.config(config, []) }} diff --git a/roles/ansible/tests/.gitignore b/roles/ansible/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/ansible/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/ansible/tests/0100_install.goss.yml b/roles/ansible/tests/0100_install.goss.yml deleted file mode 100644 index 73341a8f1..000000000 --- a/roles/ansible/tests/0100_install.goss.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- - -package: - ansible: - installed: true - -command: - dpkg -s ansible: - exit-status: 0 - stdout: -{{ if eq .Env.DISTRIBUTION_RELEASE "jessie" }} - - "/^Version: .+-\\dmanala\\d+~{{ .Env.DISTRIBUTION_RELEASE }}\\d+$/" -{{ else }} - - "/^Version: \\d+/" -{{ end }} - ansible --version: - exit-status: 0 - stdout: - - "/^ansible \\d\\.\\d\\.\\d$/" diff --git a/roles/ansible/tests/0100_install.yml b/roles/ansible/tests/0100_install.yml deleted file mode 100644 index bc40a67c9..000000000 --- a/roles/ansible/tests/0100_install.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - pre_tasks: - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['stretch'] - - import_tasks: pre_tasks/manala.yml - when: ansible_distribution_release in ['jessie'] - roles: - - manala.ansible - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/ansible/tests/0200_hosts.goss.yml b/roles/ansible/tests/0200_hosts.goss.yml deleted file mode 100644 index 330aa1651..000000000 --- a/roles/ansible/tests/0200_hosts.goss.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -file: - /etc/ansible/hosts.test: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "foo bar=baz" - - "bar" - - "[foo_var]" - - "foo" - - "bar" - - "[foo_var:vars]" - - "foo=bar" - - "bar=baz" - - "[bar:children]" - - "foo" diff --git a/roles/ansible/tests/0200_hosts.yml b/roles/ansible/tests/0200_hosts.yml deleted file mode 100644 index 9f4b52f29..000000000 --- a/roles/ansible/tests/0200_hosts.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_ansible_hosts_file: /etc/ansible/hosts.test - manala_ansible_hosts: - - foo: > - bar=baz - - bar - - foo_var: - - foo - - bar - - foo_var:vars: - - foo=bar - - bar=baz - - bar:children: - - foo - pre_tasks: - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['stretch'] - - import_tasks: pre_tasks/manala.yml - when: ansible_distribution_release in ['jessie'] - roles: - - manala.ansible - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/ansible/tests/0300_config.goss.yml b/roles/ansible/tests/0300_config.goss.yml deleted file mode 100644 index 4645573c9..000000000 --- a/roles/ansible/tests/0300_config.goss.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -file: - /etc/ansible/ansible.cfg.test: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "inventory = foo" - - "forks = 123" - - "ask_sudo_pass = False" - - "module_set_locale = True" - - "foo = bar" - - "[foo]" - - "bar = baz" diff --git a/roles/ansible/tests/0300_config.yml b/roles/ansible/tests/0300_config.yml deleted file mode 100644 index 5db3c5ff6..000000000 --- a/roles/ansible/tests/0300_config.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_ansible_config_file: /etc/ansible/ansible.cfg.test - manala_ansible_config: - - defaults: - - inventory: foo - - forks: 123 - - ask_sudo_pass: false - - module_set_locale: true - - foo: bar - - foo: - - bar: baz - pre_tasks: - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['stretch'] - - import_tasks: pre_tasks/manala.yml - when: ansible_distribution_release in ['jessie'] - roles: - - manala.ansible - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/ansible/tests/0400_host_vars.goss.1.yml b/roles/ansible/tests/0400_host_vars.goss.1.yml deleted file mode 100644 index 278b25509..000000000 --- a/roles/ansible/tests/0400_host_vars.goss.1.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- - -file: - /etc/ansible/host_vars.test: - exists: true - filetype: directory - owner: root - group: root - mode: "0755" - /etc/ansible/host_vars.test/foo.yml: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "foo: null" - - "bar: bar" - - "baz: 123" - - "qux: true" - - "quux:" - - "- foo" - - "- bar" - - "corge:" - - " baz: qux" - - " foo: bar" - /etc/ansible/host_vars.test/bar.yml: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - /etc/ansible/host_vars.test/baz.yml: - exists: false diff --git a/roles/ansible/tests/0400_host_vars.goss.2.yml b/roles/ansible/tests/0400_host_vars.goss.2.yml deleted file mode 100644 index 6b58a9ee1..000000000 --- a/roles/ansible/tests/0400_host_vars.goss.2.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -file: - /etc/ansible/host_vars.test/foo.yml: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - /etc/ansible/host_vars.test/bar.yml: - exists: false - /etc/ansible/host_vars.test/baz.yml: - exists: true - filetype: file - owner: root - group: root - mode: "0644" diff --git a/roles/ansible/tests/0400_host_vars.yml b/roles/ansible/tests/0400_host_vars.yml deleted file mode 100644 index dfe53c735..000000000 --- a/roles/ansible/tests/0400_host_vars.yml +++ /dev/null @@ -1,51 +0,0 @@ ---- - -- name: "{{ test }}.1" - hosts: debian - become: true - vars: - manala_ansible_host_vars_dir: /etc/ansible/host_vars.test - manala_ansible_host_vars: - - file: foo.yml - vars: - - foo: ~ - - bar: bar - - baz: 123 - - qux: true - - quux: - - foo - - bar - - corge: - foo: bar - baz: qux - - file: bar.yml - state: present - - file: baz.yml - state: absent - pre_tasks: - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['stretch'] - - import_tasks: pre_tasks/manala.yml - when: ansible_distribution_release in ['jessie'] - roles: - - manala.ansible - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.1.yml validate - -- name: "{{ test }}.2" - hosts: debian - become: true - vars: - manala_ansible_host_vars_dir: /etc/ansible/host_vars.test - manala_ansible_host_vars: - - file: foo.yml - - file: bar.yml - state: absent - - file: baz.yml - state: present - roles: - - manala.ansible - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.2.yml validate diff --git a/roles/ansible/tests/0401_host_vars_exclusive.goss.yml b/roles/ansible/tests/0401_host_vars_exclusive.goss.yml deleted file mode 100644 index 208828552..000000000 --- a/roles/ansible/tests/0401_host_vars_exclusive.goss.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- - -file: - /etc/ansible/host_vars.test/foo.yml: - exists: false - /etc/ansible/host_vars.test/bar.yml: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - /etc/ansible/host_vars.test/baz.yml: - exists: false diff --git a/roles/ansible/tests/0401_host_vars_exclusive.yml b/roles/ansible/tests/0401_host_vars_exclusive.yml deleted file mode 100644 index ca4f92ba7..000000000 --- a/roles/ansible/tests/0401_host_vars_exclusive.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- - -- name: "{{ test }}.1" - hosts: debian - become: true - vars: - manala_ansible_host_vars_dir: /etc/ansible/host_vars.test - manala_ansible_host_vars: - - file: foo.yml - - file: bar.yml - - file: baz.yml - pre_tasks: - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['stretch'] - - import_tasks: pre_tasks/manala.yml - when: ansible_distribution_release in ['jessie'] - roles: - - manala.ansible - -- name: "{{ test }}.2" - hosts: debian - become: true - vars: - manala_ansible_host_vars_dir: /etc/ansible/host_vars.test - manala_ansible_host_vars_exclusive: true - manala_ansible_host_vars: - - file: bar.yml - roles: - - manala.ansible - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/ansible/tests/0500_group_vars.goss.1.yml b/roles/ansible/tests/0500_group_vars.goss.1.yml deleted file mode 100644 index dd8416348..000000000 --- a/roles/ansible/tests/0500_group_vars.goss.1.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- - -file: - /etc/ansible/group_vars.test/foo.yml: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "foo: null" - - "bar: bar" - - "baz: 123" - - "qux: true" - - "quux:" - - "- foo" - - "- bar" - - "corge:" - - " baz: qux" - - " foo: bar" - /etc/ansible/group_vars.test/bar.yml: - exists: true - /etc/ansible/group_vars.test/baz.yml: - exists: false diff --git a/roles/ansible/tests/0500_group_vars.goss.2.yml b/roles/ansible/tests/0500_group_vars.goss.2.yml deleted file mode 100644 index c88c9884f..000000000 --- a/roles/ansible/tests/0500_group_vars.goss.2.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -file: - /etc/ansible/group_vars.test/foo.yml: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - /etc/ansible/group_vars.test/bar.yml: - exists: false - /etc/ansible/group_vars.test/baz.yml: - exists: true - filetype: file - owner: root - group: root - mode: "0644" diff --git a/roles/ansible/tests/0500_group_vars.yml b/roles/ansible/tests/0500_group_vars.yml deleted file mode 100644 index da02698b4..000000000 --- a/roles/ansible/tests/0500_group_vars.yml +++ /dev/null @@ -1,51 +0,0 @@ ---- - -- name: "{{ test }}.1" - hosts: debian - become: true - vars: - manala_ansible_group_vars_dir: /etc/ansible/group_vars.test - manala_ansible_group_vars: - - file: foo.yml - vars: - - foo: ~ - - bar: bar - - baz: 123 - - qux: true - - quux: - - foo - - bar - - corge: - foo: bar - baz: qux - - file: bar.yml - state: present - - file: baz.yml - state: absent - pre_tasks: - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['stretch'] - - import_tasks: pre_tasks/manala.yml - when: ansible_distribution_release in ['jessie'] - roles: - - manala.ansible - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.1.yml validate - -- name: "{{ test }}.2" - hosts: debian - become: true - vars: - manala_ansible_group_vars_dir: /etc/ansible/group_vars.test - manala_ansible_group_vars: - - file: foo.yml - - file: bar.yml - state: absent - - file: baz.yml - state: present - roles: - - manala.ansible - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.2.yml validate diff --git a/roles/ansible/tests/0501_group_vars_exclusive.goss.yml b/roles/ansible/tests/0501_group_vars_exclusive.goss.yml deleted file mode 100644 index 00536f96d..000000000 --- a/roles/ansible/tests/0501_group_vars_exclusive.goss.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- - -file: - /etc/ansible/group_vars.test/foo.yml: - exists: false - /etc/ansible/group_vars.test/bar.yml: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - /etc/ansible/group_vars.test/baz.yml: - exists: false diff --git a/roles/ansible/tests/0501_group_vars_exclusive.yml b/roles/ansible/tests/0501_group_vars_exclusive.yml deleted file mode 100644 index fe7d6782d..000000000 --- a/roles/ansible/tests/0501_group_vars_exclusive.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- - -- name: "{{ test }}.1" - hosts: debian - become: true - vars: - manala_ansible_group_vars_dir: /etc/ansible/group_vars.test - manala_ansible_group_vars: - - file: foo.yml - - file: bar.yml - - file: baz.yml - pre_tasks: - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['stretch'] - - import_tasks: pre_tasks/manala.yml - when: ansible_distribution_release in ['jessie'] - roles: - - manala.ansible - -- name: "{{ test }}.2" - hosts: debian - become: true - vars: - manala_ansible_group_vars_dir: /etc/ansible/group_vars.test - manala_ansible_group_vars_exclusive: true - manala_ansible_group_vars: - - file: bar.yml - roles: - - manala.ansible - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/ansible/tests/pre_tasks/apt_keys/manala.pgp b/roles/ansible/tests/pre_tasks/apt_keys/manala.pgp deleted file mode 100644 index 7ddda1520..000000000 --- a/roles/ansible/tests/pre_tasks/apt_keys/manala.pgp +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1 - -mQENBFbnzV0BCACdvQQktxEJdf7G85ZAXi9cQwA48leIVmxqikwR4hbvrNaanu6T -ySh1l0vKQblKAFvntPUhubX5WSeJ/Q0HoQHw7KqCgiaa+R2N5hK8JfkZxaX6/lIN -v5IVVke7Xv2oypONjUMcjDqGIWNQLP0ULCoEMD20KAYiKDlex32PrHJZajtUUZCE -stAzuMpVD0wsTOHUiXpNUlBjILOjI2dFf0X2sqzIJyVY7nx+9SPJShE5seKlcmS+ -UV1zQasMT1gU2R+WznXt5fLP/vBB6w+7cLkSyLcE615wk7trt3HBVgmBt0P8DXGw -nnxwQvmVCT4GZuuYTFAedFRRP9DziJDUTSBlABEBAAG0Gk1hbmFsYSA8Y29udGFj -dEBtYW5hbGEuaW8+iQE4BBMBAgAiBQJW581dAhsDBgsJCAcDAgYVCAIJCgsEFgID -AQIeAQIXgAAKCRCp6Eh4E5Teo+HpB/4r/5dsn9/smd0CoGsV818FICq8p2RhUX+a -X5vqIqcFZpCGEnvT0ipcOVL3Ftl108q92lv//npCvWcN51acw9+3bjsmMkxucw6q -TdxG9b/y8+LZ3OyUAxNqT6jvZIa7JT8nTJKMHeY01N0MKmofIoBO/WxQSi9OggI8 -RfdXmXTndYLGNC9jL9qWvsGFpugtjqUkhSiTySSRlu959QzGMtuqz26CKOCx5IiG -CmXYNRFdxrrdk4jhNkFMtnOTur7M39rnZTyZ6B4yHgrraqyIQRRKHMPMWBVOtL0K -Motcf3NjtN+0FyASwhZa2cQREJQ2wxI6S+8bbvaSCr1TNBQlCuxZuQENBFbnzV0B -CACmfjoB5nr0aIJqtjT2m8YdefVA13UcSWo2ECHNqQALQ+Mz8AUgG/iO45XazhWo -6acVhC6rrskokUMss4NQeXZZqlujPfySp8gYMsdQV5VtPnMBrU3tCpFYBbgjfb4s -/f0bs6Wo/evuKzQxV+sjKrq/NrCmKFf8mjA9NmjOvA5BbWf4CDnAGmqahksEQwmV -QBZ4oFl0t2gLkyT6FQn5oolQuivzXuKBDCrDdgLtOwYYeZmRgVKMSvs1FtSTR/uR -m3Tbc5zulQLF0RfvIpxseMJtmEf4Znnmk0b0KBfwnoD6sx2ynNGJEUphdP0JmJn2 -xPU0HEnAcQZQaSJpYcX007JBABEBAAGJAR8EGAECAAkFAlbnzV0CGwwACgkQqehI -eBOU3qOc0wf/QKvTldOfieDOQ9C5uBRWcAxfTkTQPLSjLF+cTh5ujbCTDiwf0aEN -OPtRsjC6Pc/sCGLCXvT3HiAZSc3/LNadlhUbi6nvoQf+XFSl++wQ423iDNrLUmi9 -/ZQS6hti79jdvk9pIE8ja4VddY5m+cOBoraC0tcSn8L1TZocklfFSfNUzY3+yY8A -1cQyrSCvpsETBsgRjj7RVhOQx5XDPPKpN9rp/Y4MIPF0PLARrqjG3sVbKmUt5TTf -GmAPbrVtxesgF9ZhUC8EZnfsI1oSkPM3nlYEnHJC2E5tM0mF3h4JOVZgJk5NrxGq -OSbTmRZCQBJF0871MKJdKzEzLI/Y/3nIjg== -=K9mA ------END PGP PUBLIC KEY BLOCK----- diff --git a/roles/ansible/tests/pre_tasks/backports.yml b/roles/ansible/tests/pre_tasks/backports.yml deleted file mode 100644 index 9094b4ecf..000000000 --- a/roles/ansible/tests/pre_tasks/backports.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -# Jessie repositories have been archived, meaning that some of them -# (backports, for instance) will remain invalid forever. -- name: Pre tasks > Backports apt repository validity - copy: - dest: /etc/apt/apt.conf.d/archive - content: | - Acquire::Check-Valid-Until "false"; - when: ansible_distribution_release in ['jessie'] - -- name: Pre tasks > Backports apt repository - apt_repository: - repo: deb http://{{ (ansible_distribution_release in ['jessie'])|ternary('archive', 'deb') }}.debian.org/debian {{ ansible_distribution_release }}-backports main - -- name: Pre tasks > Manala ansible apt preferences - copy: - dest: /etc/apt/preferences.d/ansible - content: | - Package: ansible* - Pin: release a={{ ansible_distribution_release }}-backports - Pin-Priority: 900 - when: ansible_distribution_release in ['stretch'] diff --git a/roles/ansible/tests/pre_tasks/manala.yml b/roles/ansible/tests/pre_tasks/manala.yml deleted file mode 100644 index b5b7d69fb..000000000 --- a/roles/ansible/tests/pre_tasks/manala.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- - -- name: Pre tasks > Manala apt key - apt_key: - file: pre_tasks/apt_keys/manala.pgp - id: 1394DEA3 - -- name: Pre tasks > Manala apt repository - apt_repository: - repo: deb [arch=amd64] http://debian.manala.io {{ ansible_distribution_release }} main - -- name: Pre tasks > Manala preferences - copy: - dest: /etc/apt/preferences.d/ansible - content: | - Package: ansible* - Pin: origin debian.manala.io - Pin-Priority: 900 diff --git a/roles/ansible_galaxy/.gitignore b/roles/ansible_galaxy/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/ansible_galaxy/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/ansible_galaxy/.manala/make/Makefile b/roles/ansible_galaxy/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/ansible_galaxy/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/ansible_galaxy/.manala/make/Makefile.docker b/roles/ansible_galaxy/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/ansible_galaxy/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/ansible_galaxy/.manala/make/Makefile.host b/roles/ansible_galaxy/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/ansible_galaxy/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/ansible_galaxy/.manala/make/Makefile.manala b/roles/ansible_galaxy/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/ansible_galaxy/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/ansible_galaxy/.manala/make/Makefile.travis b/roles/ansible_galaxy/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/ansible_galaxy/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/ansible_galaxy/.manala/make/gmsl/__gmsl b/roles/ansible_galaxy/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/ansible_galaxy/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/ansible_galaxy/.manala/make/gmsl/gmsl b/roles/ansible_galaxy/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/ansible_galaxy/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/ansible_galaxy/.travis.yml b/roles/ansible_galaxy/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/ansible_galaxy/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/ansible_galaxy/CHANGELOG.md b/roles/ansible_galaxy/CHANGELOG.md deleted file mode 100644 index c44363bbf..000000000 --- a/roles/ansible_galaxy/CHANGELOG.md +++ /dev/null @@ -1,59 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.3] - 2020-08-28 -### Changed -- Explicit file permissions - -## [2.0.2] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.1] - 2019-11-29 -### Changed -- Update 'lookup' to use 'query' -- Minimum required version of ansible up to 2.5.0 - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.6] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.5] - 2019-05-21 -### Fixed -- Alt galaxy bin variable handling when requirement check is unsuccessful -- Disable changed status when writing temporary roles requirements file in check mode - -## [1.0.4] - 2018-10-17 -### Fixed -- Python 3 compatibility - -### Changed -- Ignore SSL certificate validation errors on debian wheezy when using - official ansible galaxy bin (incompatible default python version) - -## [1.0.3] - 2018-06-05 -### Changed -- Replace deprecated jinja tests used as filters -- Replace deprecated uses of "include" - -## [1.0.2] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.1] - 2017-11-10 -### Added -- Clean temporary roles requirements file - -## [1.0.0] - 2017-06-21 -### Added -- Handle alternatives -- Handle roles diff --git a/roles/ansible_galaxy/Makefile b/roles/ansible_galaxy/Makefile deleted file mode 100644 index f50dc04e8..000000000 --- a/roles/ansible_galaxy/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.ansible_galaxy -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/ansible_galaxy/README.md b/roles/ansible_galaxy/README.md index be5896e07..89205c06a 100644 --- a/roles/ansible_galaxy/README.md +++ b/roles/ansible_galaxy/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Ansible Galaxy [![Build Status](https://travis-ci.org/manala/ansible-role-ansible_galaxy.svg?branch=master)](https://travis-ci.org/manala/ansible-role-ansible_galaxy) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Ansible Galaxy This role will deal with the setup of __Ansible Galaxy__. -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,27 +14,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.ansible_galaxy -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.ansible_galaxy -``` +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| ------------------------------ | ------------------------------ | ------- | ------------ | -| `manala_ansible_galaxy_roles` | [] | Array | Roles | -| `manala_ansible_galaxy_force` | `manala_ansible_galaxy.update` | Boolean | Force | -| `manala_ansible_galaxy.update` | false | Boolean | Update roles | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Roles @@ -54,7 +26,7 @@ Using ansible galaxy requirements file: ```yaml manala_ansible_galaxy_roles: - - manala.skeleton + - ansistrano.deploy ``` ### Flags @@ -73,13 +45,16 @@ manala: ```yaml - hosts: servers - roles: - - { role: manala.ansible_galaxy } + tasks: + - import_role: + name: manala.roles.ansible_galaxy ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/ansible_galaxy/lookup_plugins/.gitignore b/roles/ansible_galaxy/lookup_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/ansible_galaxy/lookup_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/ansible_galaxy/lookup_plugins/manala_ansible_galaxy_roles.py b/roles/ansible_galaxy/lookup_plugins/manala_ansible_galaxy_roles.py deleted file mode 100644 index 0d48bec85..000000000 --- a/roles/ansible_galaxy/lookup_plugins/manala_ansible_galaxy_roles.py +++ /dev/null @@ -1,46 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.module_utils.six import string_types -from ansible.errors import AnsibleError - -class LookupModule(LookupBase): - - def run(self, terms, variables=None, **kwargs): - - results = [] - - for term in self._flatten(terms): - - items = [] - - # Short syntax - if isinstance(term, string_types): - items.append({ - 'src': term - }) - else: - - # Must be a dict - if not isinstance(term, dict): - raise AnsibleError('Expect a dict') - - # Check index key - if 'src' not in term: - raise AnsibleError('Expect "src" key') - - items.append(term) - - # Merge by index key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['src'] == item['src']: - results[i] = item - itemFound = True - break - if not itemFound: - results.append(item) - - return results diff --git a/roles/ansible_galaxy/meta/main.yml b/roles/ansible_galaxy/meta/main.yml index 7a8b50dfc..86feea249 100644 --- a/roles/ansible_galaxy/meta/main.yml +++ b/roles/ansible_galaxy/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: ansible_galaxy - author: Manala - company: Manala - description: Handle ansible galaxy - license: MIT - min_ansible_version: 2.5.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: ansible_galaxy + author: Manala + company: Manala + description: Handle ansible galaxy + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - ansible diff --git a/roles/ansible_galaxy/tasks/alternatives.yml b/roles/ansible_galaxy/tasks/alternatives.yml deleted file mode 100644 index 72f06fc5e..000000000 --- a/roles/ansible_galaxy/tasks/alternatives.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- name: alternatives > Check alt-galaxy - command: which alt-galaxy - changed_when: false - failed_when: false - register: __manala_ansible_galaxy_alternatives_check_alt_galaxy_result - when: not manala_ansible_galaxy_bin - -- name: alternatives > Set alt-galaxy - set_fact: - manala_ansible_galaxy_bin: "{{ __manala_ansible_galaxy_alternatives_check_alt_galaxy_result.stdout|default(None) }}" - manala_ansible_galaxy_force: true # Alt-galaxy force mode need to be explicitly set. See: https://github.com/gantsign/alt-galaxy/issues/30 - when: not manala_ansible_galaxy_bin and __manala_ansible_galaxy_alternatives_check_alt_galaxy_result is succeeded diff --git a/roles/ansible_galaxy/tasks/main.yml b/roles/ansible_galaxy/tasks/main.yml index d8339065b..885764f33 100644 --- a/roles/ansible_galaxy/tasks/main.yml +++ b/roles/ansible_galaxy/tasks/main.yml @@ -1,14 +1,5 @@ --- -# Alternatives -- import_tasks: alternatives.yml - tags: - - manala_ansible_galaxy - - manala_ansible_galaxy.alternatives - # Ensure alternatives in update mode - - manala_ansible_galaxy.update - - manala.update - # Roles - import_tasks: roles.yml tags: diff --git a/roles/ansible_galaxy/tasks/roles.yml b/roles/ansible_galaxy/tasks/roles.yml index 53394a0b4..d9ad0c69b 100644 --- a/roles/ansible_galaxy/tasks/roles.yml +++ b/roles/ansible_galaxy/tasks/roles.yml @@ -4,7 +4,7 @@ copy: dest: /tmp/manala_ansible_galaxy_roles.yml content: | - {% for role in query('manala_ansible_galaxy_roles', manala_ansible_galaxy_roles) %} + {% for role in query('manala.roles.ansible_galaxy_roles', manala_ansible_galaxy_roles) %} - src: {{ role.src }} {% if role.scm is defined %} scm: {{ role.scm }} diff --git a/roles/ansible_galaxy/tests/.gitignore b/roles/ansible_galaxy/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/ansible_galaxy/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/ansible_galaxy/tests/0000_default.yml b/roles/ansible_galaxy/tests/0000_default.yml deleted file mode 100644 index 6d147f2cf..000000000 --- a/roles/ansible_galaxy/tests/0000_default.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_role: - name: manala.ansible_galaxy - vars: - manala_ansible_galaxy_roles: - - ansistrano.deploy - - jdauphant.nginx - - src: jdauphant.nginx - version: v1.11.4 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/apparmor/.gitignore b/roles/apparmor/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/apparmor/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/apparmor/.manala/make/Makefile b/roles/apparmor/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/apparmor/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/apparmor/.manala/make/Makefile.docker b/roles/apparmor/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/apparmor/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/apparmor/.manala/make/Makefile.host b/roles/apparmor/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/apparmor/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/apparmor/.manala/make/Makefile.manala b/roles/apparmor/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/apparmor/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/apparmor/.manala/make/Makefile.travis b/roles/apparmor/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/apparmor/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/apparmor/.manala/make/gmsl/__gmsl b/roles/apparmor/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/apparmor/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/apparmor/.manala/make/gmsl/gmsl b/roles/apparmor/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/apparmor/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/apparmor/.travis.yml b/roles/apparmor/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/apparmor/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/apparmor/CHANGELOG.md b/roles/apparmor/CHANGELOG.md deleted file mode 100644 index 4080a3e78..000000000 --- a/roles/apparmor/CHANGELOG.md +++ /dev/null @@ -1,37 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.2] - 2020-08-28 -### Changed -- Explicit file permissions - -## [2.0.1] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.3] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.2] - 2018-06-05 -### Changed -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.0] - 2017-05-30 -### Added -- Handle installation -- Handle configs diff --git a/roles/apparmor/Makefile b/roles/apparmor/Makefile deleted file mode 100644 index e3592fd3b..000000000 --- a/roles/apparmor/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.apparmor -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/apparmor/README.md b/roles/apparmor/README.md index 81f965c6d..db742a8ca 100644 --- a/roles/apparmor/README.md +++ b/roles/apparmor/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: AppArmor [![Build Status](https://travis-ci.org/manala/ansible-role-apparmor.svg?branch=master)](https://travis-ci.org/manala/ansible-role-apparmor) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: AppArmor This role will deal with the setup of [AppArmor](http://apparmor.net/). -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,34 +14,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.apparmor -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.apparmor -``` - -## Role Handlers - -| Name | Type | Description | -| ----------------- | ------- | ----------------------- | -| `apparmor reload` | Service | Reload apparmor configs | +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| ------------------------------------------ | ----------------- | ------ | -------------------------------------- | -| `manala_apparmor_install_packages` | ~ | Array | Dependency packages to install | -| `manala_apparmor_install_packages_default` | ['apparmor'] | Array | Default dependency packages to install | -| `manala_apparmor_configs_dir` | '/etc/apparmor.d' | String | Configurations directory path | -| `manala_apparmor_configs` | [] | Array | Configurations templates | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ## Example playbook @@ -62,18 +27,21 @@ Using ansible galaxy requirements file: vars: manala_apparmor_configs: - - file: lxc/lxc-profile-a + - file: lxc/lxc-profile-a template: lxc-default.j2 - - file: lxc/lxc-old-profile - state: absent + - file: lxc/lxc-old-profile + state: absent - roles: - - { role: manala.apparmor } + tasks: + - import_role: + name: manala.roles.apparmor ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/apparmor/defaults/main.yml b/roles/apparmor/defaults/main.yml index 1d9aec580..49c7a031c 100644 --- a/roles/apparmor/defaults/main.yml +++ b/roles/apparmor/defaults/main.yml @@ -6,5 +6,7 @@ manala_apparmor_install_packages_default: - apparmor # Configs +manala_apparmor_configs_exclusive: false manala_apparmor_configs_dir: /etc/apparmor.d +manala_apparmor_configs_defaults: {} manala_apparmor_configs: [] diff --git a/roles/apparmor/handlers/main.yml b/roles/apparmor/handlers/main.yml index c2a40dfd3..3ce61a3d3d 100644 --- a/roles/apparmor/handlers/main.yml +++ b/roles/apparmor/handlers/main.yml @@ -2,5 +2,7 @@ - name: apparmor reload service: - name: apparmor + name: "{{ item }}" state: reloaded + loop: + - apparmor diff --git a/roles/apparmor/meta/main.yml b/roles/apparmor/meta/main.yml index 965e044d0..28f19e82e 100644 --- a/roles/apparmor/meta/main.yml +++ b/roles/apparmor/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: apparmor - author: Manala - company: Manala - description: Install and configure AppArmor - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: apparmor + author: Manala + company: Manala + description: Install and configure AppArmor + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - security diff --git a/roles/apparmor/tasks/configs.yml b/roles/apparmor/tasks/configs.yml index 456557d37..bcaba6f52 100644 --- a/roles/apparmor/tasks/configs.yml +++ b/roles/apparmor/tasks/configs.yml @@ -1,32 +1,43 @@ --- -- name: configs > Ensures destination directories exists - file: - path: "{{ manala_apparmor_configs_dir ~ '/' ~ item.file | dirname }}" - state: directory - recurse: true - owner: root - group: root - mode: "0755" - with_items: "{{ manala_apparmor_configs }}" +- name: configs > Exclusive + find: + path: "{{ manala_apparmor_configs_dir }}" + file_type: file + patterns: "*" + changed_when: false + register: __manala_apparmor_configs_exclusive_find + when: manala_apparmor_configs_exclusive -- name: configs > Templates +- name: configs > Templates present template: src: "{{ item.template }}" - dest: "{{ manala_apparmor_configs_dir }}/{{ item.file }}" + dest: "{{ item.file }}" owner: root group: root mode: "0644" - when: item.state|default('present') != 'absent' - with_items: "{{ manala_apparmor_configs }}" + loop: "{{ query( + 'manala.roles.templates_exclusive', + manala_apparmor_configs, + __manala_apparmor_configs_exclusive_find.files|default([]), + manala_apparmor_configs_dir, + manala_apparmor_configs_defaults.template|default('configs/_default.j2', true), + wantstate='present' + ) }}" notify: - apparmor reload -- name: configs > Remove files +- name: configs > Files absent file: - path: "{{ manala_apparmor_configs_dir }}/{{ item.file }}" + path: "{{ item.file }}" state: absent - when: item.state|default('present') == 'absent' - with_items: "{{ manala_apparmor_configs }}" + loop: "{{ query( + 'manala.roles.templates_exclusive', + manala_apparmor_configs, + __manala_apparmor_configs_exclusive_find.files|default([]), + manala_apparmor_configs_dir, + manala_apparmor_configs_defaults.template|default('configs/_default.j2', true), + wantstate='absent' + ) }}" notify: - apparmor reload diff --git a/roles/apparmor/tasks/install.yml b/roles/apparmor/tasks/install.yml index eb7008480..fc08012c9 100644 --- a/roles/apparmor/tasks/install.yml +++ b/roles/apparmor/tasks/install.yml @@ -2,7 +2,9 @@ - name: install > Packages apt: - name: "{{ manala_apparmor_install_packages|default(manala_apparmor_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_apparmor_install_packages|default(manala_apparmor_install_packages_default, True) }}" diff --git a/roles/apparmor/templates/configs/_default.j2 b/roles/apparmor/templates/configs/_default.j2 new file mode 100644 index 000000000..98112f114 --- /dev/null +++ b/roles/apparmor/templates/configs/_default.j2 @@ -0,0 +1,3 @@ +{%- set config = item.config|default('') -%} + +{{ config }} diff --git a/roles/apparmor/tests/.gitignore b/roles/apparmor/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/apparmor/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/apparmor/tests/0100_install.yml b/roles/apparmor/tests/0100_install.yml deleted file mode 100644 index 9df44cd09..000000000 --- a/roles/apparmor/tests/0100_install.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - roles: - - manala.apparmor - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/apt/.gitignore b/roles/apt/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/apt/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/apt/.manala/make/Makefile b/roles/apt/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/apt/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/apt/.manala/make/Makefile.docker b/roles/apt/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/apt/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/apt/.manala/make/Makefile.host b/roles/apt/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/apt/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/apt/.manala/make/Makefile.manala b/roles/apt/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/apt/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/apt/.manala/make/Makefile.travis b/roles/apt/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/apt/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/apt/.manala/make/gmsl/__gmsl b/roles/apt/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/apt/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/apt/.manala/make/gmsl/gmsl b/roles/apt/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/apt/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/apt/.travis.yml b/roles/apt/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/apt/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/apt/CHANGELOG.md b/roles/apt/CHANGELOG.md deleted file mode 100644 index ca8df1b62..000000000 --- a/roles/apt/CHANGELOG.md +++ /dev/null @@ -1,447 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.37] - 2021-12-10 -### Added -- PHP 8.1 support - -## [2.0.36] - 2021-11-30 -### Added -- Add GlusterFS 6.10 repository - -## [2.0.35] - 2021-11-17 -### Added -- Add HAProxy 2.4 repository - -## [2.0.34] - 2021-10-14 -### Added -- Mariadb 10.6 support - -## [2.0.33] - 2021-10-01 -### Added -- Add multi architecture support (amd64/arm64/armhf) - -## [2.0.32] - 2021-09-21 -### Added -- Maxscale 2.5 support -- Maxscale 6.1 support - -## [2.0.31] - 2021-06-18 -### Changed -- Mica repository and key - -## [2.0.30] - 2021-05-17 -### Added -- Nodejs 16 support - -## [2.0.30] - 2021-04-27 -### Added -- Add Galera 4.8 -- Add Galera wsrep 8.0.22, 8.0.23 - -## [2.0.29] - 2021-03-24 -### Added -- Add Kopia - -## [2.0.28] - 2021-03-08 -- Deprecate dict's array sources list - -## [2.0.27] - 2021-03-03 -### Changed -- "packages" tasks must occurs before "holds" one, so that package can be held right after their installation - -## [2.0.26] - 2021-03-02 -### Added -- Add Galera 4 repositories - -## [2.0.25] - 2021-02-25 -### Added -- PHP 8.0 support - -### Changed -- Group package by state, respecting order - -## [2.0.24] - 2021-01-18 -- Add Galera_3_31 repository to set on Jessie (last version before deprecation) - -## [2.0.23] - 2021-01-07 -### Removed -- Drop elasticsearch 1.5/1.6 support - -## [2.0.22] - 2020-12-15 -### Added -- Nodejs 14 support - -## [2.0.21] - 2020-12-09 -### Removed -- MaxScale version inferior to 2.2 support - -## [2.0.20] - 2020-10-26 -### Added -- Flatten configs array -- Flatten holds array -- Flatten keys array -- Flatten packages array -- Flatten preferences array -- Flatten repositories array -- Flatten components array - -## [2.0.19] - 2020-10-20 -### Changed -- Configs file names based on template name if not provided - -## [2.0.18] - 2020-10-16 -### Changed -- Update Maxscale 2.4 key patterns - -## [2.0.17] - 2020-10-11 -### Added -- Add Mongodb 4.4 repositories - -### Changed -- Handle holds by state (present|absent|ignore) - -## [2.0.16] - 2020-10-06 -### Added -- Add 1.8 and 2.2 HAProxy repositories - -## [2.0.15] - 2020-09-29 -### Added -- MariaDB 10.5 repository pattern -- Configs|Packages|Preferences|Repositories can be individually ignored - -### Changed -- Use unified exclusive template lookup for configs - -## [2.0.14] - 2020-08-28 -### Changed -- Explicit file permissions on repositories - -## [2.0.13] - 2020-08-26 -### Changed -- Explicit file permissions - -## [2.0.12] - 2020-04-34 -### Changed -- Update Gitlab key patterns - -## [2.0.11] - 2020-03-13 -### Added -- MariaDB 10.4 repository pattern - -## [2.0.10] - 2020-03-12 -### Added -- MaxScale 2.4 repository pattern - -## [2.0.9] - 2020-02-24 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.8] - 2020-02-18 -### Removed -- GlusterFS arm64 support - -### Added -- Add Raspbian support -- Add Unifi repository - -## [2.0.7] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.6] - 2020-02-07 -### Added -- Upstream Haproxy repo - -## [2.0.5] - 2020-01-06 -### Changed -- Update Logentries repository patterns - -### Added -- PHP 7.4 support - -## [2.0.4] - 2019-11-29 -### Changed -- Update 'lookup' to use 'query' -- Minimum required version of ansible up to 2.5.0 - -## [2.0.3] - 2019-11-28 -### Fixed -- Repositories and keys handlings for preferences pattern syntax - -### Added -- Explicit error message when using unknown repository pattern -- Default repository pattern - -## [2.0.2] - 2019-11-27 -### Added -- Allow preferences pattern syntax - -## [2.0.1] - 2019-11-26 -### Added -- Mongodb 3.0/3.4/4.2 repository patterns - -### Fixed -- Mongodb key patterns - -## [2.0.0] - 2019-11-21 -### Removed -- Unbuntu support -- Debian wheezy support - -## [1.0.45] - 2019-11-07 -### Fixed -- Ansible repository & key pattern (again) - -## [1.0.44] - 2019-11-06 -### Fixed -- Ansible repository & key pattern - -## [1.0.43] - 2019-11-06 -### Added -- Ansible repository & key pattern - -## [1.0.42] - 2019-10-24 -### Added -- MySQL 8 repository pattern - -## [1.0.41] - 2019-10-24 -### Added -- Debian buster support -- Nodejs 12 support -- Varnish 6.1 support - -## [1.0.40] - 2019-10-21 -### Added -- Graylog_sidecat key pattern - -## [1.0.39] - 2019-09-20 -### Added -- Elasticsearch 7 support - -## [1.0.38] - 2019-07-23 -### Added -- Newrelic-infra repository & key pattern - -## [1.0.37] - 2019-05-21 -### Added -- Glusterfs repository & key pattern - -## [1.0.36] - 2019-04-16 -### Fixed -- Switch wheezy debian security repository to archive - -### Added -- Handle holded packages -- Debian multimedia/multimedia_backports repository support - -## [1.0.35] - 2019-04-01 -### Fixed -- Use debian wheezy/jessie archive repositories - -### Added -- Mongodb 4.0 repository pattern -- Handle configs - -### Changed -- Introduce new Mongodb key pattern and rename legacy one - -## [1.0.34] - 2019-03-19 -### Changed -- Update sury php key (see: https://www.patreon.com/posts/dpa-new-signing-25451165) - -## [1.0.33] - 2019-01-25 -### Added -- Add Mica (https://www.obiba.org/pages/products/mica/) support - -## [1.0.32] - 2019-01-14 -### Fixed -- Blackfire key pattern - -## [1.0.31] - 2019-01-14 -### Added -- MaxScale 2.3 repository pattern - -## [1.0.30] - 2019-01-10 -### Fixed -- Grafana repository & key pattern -- Repository file is now well prefixed by repositories dir - -## [1.0.29] - 2018-12-13 -### Added -- Owncloud repository pattern -- PHP 7.3 support - -## [1.0.28] - 2018-12-04 -### Added -- Matomo repository pattern - -## [1.0.27] - 2018-12-03 -### Added -- Repository file can be specified - -## [1.0.26] - 2018-11-15 -### Changed -- Switch back problematics keys sources from ubuntu keyserver to direct url, - in order to work around strict ring checks introduced by gnupg2 2.1.18-8~deb9u3 - on debian stretch (see: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=913614) - -## [1.0.25] - 2018-10-31 -### Added -- Handle preferences & repositories states (present|absent) -- MariaDB 10.3 repository pattern - -## [1.0.24] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.23] - 2018-08-21 -### Fixed -- MaxScale minor versions repository patterns keys - -## [1.0.22] - 2018-08-21 -### Added -- MaxScale minor versions repository patterns - -## [1.0.21] - 2018-08-13 -### Added -- Nodejs 10 support - -## [1.0.20] - 2018-07-10 -### Fixed -- Sensu repository & key pattern url - -## [1.0.19] - 2018-06-26 -### Added -- Certbot preferences pattern missing dependencies -- Thumbor preferences pattern - -### Removed -- Elasticsearch < 2.0.0 support on debian stretch - -### Changed -- Cleanup distribution handling (blacklist old stables instead of whitelist current stable) - -## [1.0.18] - 2018-06-05 -### Added -- Percona repository pattern -- Handle dependency packages to install -- Elasticsearch 6 support -- MaxScale 2.2.6 repository pattern - -### Fixed -- Fix wrong Sensu APT source distribution ID -- Fix wrong maxscale keyserver - -### Changed -- Update aptly key -- Replace deprecated jinja tests used as filters -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.17] - 2018-03-21 -### Added -- MongoDB 3.6 support - -## [1.0.16] - 2018-03-14 -### Added -- Certbot preferences pattern - -## [1.0.15] - 2018-01-15 -### Fixed -- Use keyserver.ubuntu.com for influxdata key (avoid everlasting sni issues with - wheezy) - -## [1.0.14] - 2017-12-08 -### Added -- PHP 7.2 support - -## [1.0.13] - 2017-12-06 -### Added -- Debian stretch support - -### Changed -- Adjust tests for debian stretch support - -## [1.0.12] - 2017-11-21 -### Added -- MaxScale 2.1.10 support -- Proxmox key - -### Changed -- Always use keyserver.ubuntu.com when possible - -### Fixed -- RabbitMQ key id -- Make Grafana repository distribution release dependent -- Make MongoDB repository distribution release dependent - -## [1.0.11] - 2017-11-06 -### Added -- Nodejs 9 support - -## [1.0.10] - 2017-11-02 -### Fixed -- Galera debian repositories - -## [1.0.9] - 2017-10-28 -### Fixed -- Docker repository key/url - -## [1.0.8] - 2017-10-24 -### Changed -- Pam Ssh Agent Auth preferences pattern - -## [1.0.7] - 2017-10-20 -### Fixed -- Debian httpredir.debian.org deprecated in favour of deb.debian.org -- Debian security repository trailing slash - -## [1.0.6] - 2017-10-17 -### Added -- Backports sloppy support -- Elasticsearch 5 support - -### Fixed -- Elasticsearch repositories patterns source urls -- Elasticsearch keys patterns urls - -### Fixed -- Mongodb repository apt key - -## [1.0.5] - 2017-10-09 -### Added -- Nodejs 8 support - -### Changed -- Fix ansible 2.3 warnings "when statements should not include jinja2 templating delimiters" - -## [1.0.4] - 2017-09-29 -### Changed -- Fix varnish 4.0 repository and key - -## [1.0.3] - 2017-09-28 -### Changed -- Update yarn apt repository and key url - -## [1.0.2] - 2017-09-25 -### Changed -- Change testing manual debian package (smaller and more reliable) - -## [1.0.1] - 2017-05-12 -### Added -- `httpie` package preference - -## [1.0.0] - 2017-05-11 -### Added -- Handle sources list -- Handle preferences -- Handle repositories keys -- Handle repositories -- Handle update -- Handle packages diff --git a/roles/apt/Makefile b/roles/apt/Makefile deleted file mode 100644 index 05c0e2c68..000000000 --- a/roles/apt/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.apt -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/apt/README.md b/roles/apt/README.md index 0d5e3e2ae..aba66b672 100644 --- a/roles/apt/README.md +++ b/roles/apt/README.md @@ -1,16 +1,4 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Apt [![Build Status](https://travis-ci.org/manala/ansible-role-apt.svg?branch=master)](https://travis-ci.org/manala/ansible-role-apt) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Apt This role will add third party sources to the package manager by: - Adding source URL as new repository @@ -18,7 +6,7 @@ This role will add third party sources to the package manager by: - Managing packages preferences files (aka. pinning) - Installing packages -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -30,51 +18,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.apt -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.apt -``` - -## Role Handlers - -None +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -### Definition - -| Name | Default | Type | Description | -| ------------------------------------- | ----------------------------------------------------- | ------------ | -------------------------------------- | -| `manala_apt_configs_exclusive` | false | Boolean | Configurations exclusivity | -| `manala_apt_configs_dir` | '/etc/apt/apt.conf.d' | String | Configurations dir path | -| `manala_apt_configs_defaults` | {} | Array | Configurations defaults | -| `manala_apt_configs` | [] | Array | Configurations | -| `manala_apt_install_packages` | ~ | Array | Dependency packages to install | -| `manala_apt_install_packages_default` | ['apt-transport-https', 'openssl', 'ca-certificates'] | Array | Default dependency packages to install | -| `manala_apt_components` | ['main'] | Array | Collection of components | -| `manala_apt_sources_list_file` | '/etc/apt/sources.list' | String | Sources list file path | -| `manala_apt_sources_list_template` | ~ | String | Sources list template path | -| `manala_apt_sources_list` | ~ | String/Array | Sources list | -| `manala_apt_repositories_exclusive` | false | Boolean | Repositories exclusivity | -| `manala_apt_repositories` | [] | Array | Repositories | -| `manala_apt_preferences_exclusive` | false | Boolean | Preferences exclusivity | -| `manala_apt_preferences_dir` | '/etc/apt/preferences.d' | String | Preferences dir path | -| `manala_apt_preferences_defaults` | {} | Array | Preferences defaults | -| `manala_apt_preferences` | [] | Array | Preferences | -| `manala_apt_holds_exclusive` | false | Array | Holds exclusivity | -| `manala_apt_holds` | [] | Array | Collection of holds | -| `manala_apt_packages` | [] | Array | Collection of packages | -| `manala_apt_cache_valid_time` | 3600 | Integer | Permitted age of apt cache, in seconds | -| `manala_apt.update` | false | Boolean | Update packages | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Example @@ -85,14 +33,15 @@ None - contrib manala_apt_preferences: - git@backports - - dotdeb:100 - - php@dotdeb_php56:300 + - sury_php:100 + - php@sury_php:300 - nginx@nginx manala_apt_packages: - xfonts-75dpi - http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-{{ ansible_distribution_release }}-amd64.deb - roles: - - role: manala.apt + tasks: + - import_role: + name: manala.roles.apt ``` ### Configs @@ -112,10 +61,6 @@ manala_apt_configs: - file: foo_content config: | APT::Install-Recommends "false"; - # Dicts array config based (deprecated) - - file: foo - config: - - Acquire::Check-Valid-Until: true # Ensure config is absent - file: absent state: absent # "present" by default @@ -163,14 +108,6 @@ manala_apt_sources_list: | deb http://deb.debian.org/debian {{ ansible_distribution_release }}-updates main ``` -Use dict's array (deprecated): - -```yaml -manala_apt_sources_list: - - deb: http://deb.debian.org/debian {{ ansible_distribution_release }} main - - deb http://deb.debian.org/debian {{ ansible_distribution_release }} contrib -``` - ### Repositories Concise, pattern based @@ -182,7 +119,6 @@ manala_apt_repositories: - partner - backports - backports_sloppy - - dotdeb - nginx - bearstech - nodesource_0_10 @@ -227,7 +163,7 @@ Verbose, pattern based ```yaml manala_apt_repositories: - - pattern: backports + - repository: backports state: absent ``` @@ -238,7 +174,7 @@ manala_apt_repositories: - source: deb http://pkg.jenkins-ci.org/debian binary/ key: url: http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key - id: D50582E6 + id: D50582E6 - source: deb https://enterprise.proxmox.com/debian {{ ansible_distribution_release }} pve-enterprise state: absent # Ignore repository @@ -265,9 +201,8 @@ Note that referenced repositories will automatically be include as present using ```yaml manala_apt_preferences: - git@backports # "git*"" from debian backports repository, high priority - - dotdeb:100 # "*" from dotdeb repository, low priority - - php@dotdeb # "php*" from dotdeb repository, high priority - - redis@dotdeb # "redis*" from dotdeb repository, high priority + - sury_php:100 # "*" from sury_php repository, low priority + - php@sury_php # "php*" from sury_php repository, high priority - libssl1.0.0@backports # "libssl1.0.0" from debian backports repository, high priority (in this case "libssl1.0.0" is not a pre-defined preference pattern; as a matter of consequence the package is directly used) # Pattern syntax - preference: ansible@ansible @@ -278,15 +213,15 @@ Verbose ```yaml manala_apt_preferences: - - package: '*' - pin: release o=Debian,a=stable + - package: '*' + pin: release o=Debian,a=stable priority: 600 - file: dotdeb - - package: 'php-*' - pin: release o=Debian,a=stable - priority: 900 - file: php - state: absent + file: sury_php + - package: 'php-*' + pin: release o=Debian,a=stable + priority: 1000 + file: php + state: absent # Ignore preference - file: foo state: ignore @@ -308,9 +243,6 @@ manala_apt_holds: # Ignore hold - package: qux state: ignore - # Deprecated - - package: quux - hold: true # or false :) # Flatten holds - "{{ my_custom_holds_array }}" ``` @@ -334,7 +266,7 @@ Verbose ```yaml manala_apt_packages: - - package: bzip2 # Name of package, required + - package: bzip2 # Name of package, required state: absent # State of package, optional, default "present" force: true # Force installation, optional # Ignore package @@ -356,9 +288,11 @@ manala: update: true ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/apt/defaults/main.yml b/roles/apt/defaults/main.yml index 168b25b1d..3a918f1b9 100644 --- a/roles/apt/defaults/main.yml +++ b/roles/apt/defaults/main.yml @@ -3,9 +3,7 @@ # Configs manala_apt_configs_exclusive: false manala_apt_configs_dir: /etc/apt/apt.conf.d -manala_apt_configs_template: ~ # Deprecated -manala_apt_configs_defaults: - template: "{{ manala_apt_configs_template }}" # Ensure backward compatibility +manala_apt_configs_defaults: {} manala_apt_configs: [] # Install @@ -30,8 +28,7 @@ manala_apt_repositories: [] # Preferences manala_apt_preferences_exclusive: false manala_apt_preferences_dir: /etc/apt/preferences.d -manala_apt_preferences_defaults: - template: ~ +manala_apt_preferences_defaults: {} manala_apt_preferences: [] # Keys diff --git a/roles/apt/filter_plugins/.gitignore b/roles/apt/filter_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/apt/filter_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/apt/filter_plugins/manala_apt.py b/roles/apt/filter_plugins/manala_apt.py deleted file mode 100644 index 5352b3ca7..000000000 --- a/roles/apt/filter_plugins/manala_apt.py +++ /dev/null @@ -1,26 +0,0 @@ -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -from ansible.errors import AnsibleFilterError - -ARCHITECTURE_MAP = { - 'x86_64': 'amd64', - 'aarch64': 'arm64', - 'armv7l': 'armhf', -} - -def architecture(architecture): - if architecture not in ARCHITECTURE_MAP: - raise AnsibleFilterError('unsupported "%s" architecture' % architecture) - return ARCHITECTURE_MAP[architecture] - - -class FilterModule(object): - ''' Manala apt jinja2 filters ''' - - def filters(self): - filters = { - 'manala_apt_architecture': architecture, - } - - return filters diff --git a/roles/apt/lookup_plugins/.gitignore b/roles/apt/lookup_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/apt/lookup_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/apt/lookup_plugins/manala_apt_holds.py b/roles/apt/lookup_plugins/manala_apt_holds.py deleted file mode 100644 index 6d792ceb8..000000000 --- a/roles/apt/lookup_plugins/manala_apt_holds.py +++ /dev/null @@ -1,92 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.module_utils.six import string_types -from ansible.errors import AnsibleError -from ansible.module_utils._text import to_text - - -class LookupModule(LookupBase): - - def _recursive_flatten(self, terms): - if not isinstance(terms, list): - raise AnsibleError('Expect a list but was a %s' % type(terms)) - ret = [] - for term in terms: - if isinstance(term, (list, tuple)): - ret.extend( - self._recursive_flatten(term) - ) - else: - ret.append(term) - return ret - - def run(self, terms, variables=None, **kwargs): - - results = [] - - holds = self._recursive_flatten(terms[0]) - exclusives = self._flatten(terms[1]) - - itemDefault = { - 'state': 'present' - } - - # Unhold exclusives - for hold in exclusives: - item = itemDefault.copy() - item.update({ - 'package': hold, - 'state': 'absent' - }) - results.append(item) - - for hold in holds: - - items = [] - - item = itemDefault.copy() - - # Short syntax - if isinstance(hold, string_types): - item.update({ - 'package': hold, - 'state': 'present' - }) - else: - # Must be a dict - if not isinstance(hold, dict): - raise AnsibleError('Expect a dict but was a %s' % type(hold)) - - # Check package key - if 'package' not in hold: - raise AnsibleError('Expect "package" key') - - # Deprecated - if ('hold' in hold) and ('state' not in hold): - hold['state'] = 'present' if hold['hold'] else 'absent' - - item.update(hold) - - if item['state'] not in ['present', 'absent', 'ignore']: - raise AnsibleError('Expect a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) - - if item['state'] == 'ignore': - continue - - items.append(item) - - # Merge by index key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['package'] == item['package']: - results[i] = item - itemFound = True - break - - if not itemFound: - results.append(item) - - return results diff --git a/roles/apt/lookup_plugins/manala_apt_keys.py b/roles/apt/lookup_plugins/manala_apt_keys.py deleted file mode 100644 index 66572a696..000000000 --- a/roles/apt/lookup_plugins/manala_apt_keys.py +++ /dev/null @@ -1,75 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.module_utils.six import string_types -from ansible.errors import AnsibleError - - -class LookupModule(LookupBase): - - def _recursive_flatten(self, terms): - if not isinstance(terms, list): - raise AnsibleError('Expect a list but was a %s' % type(terms)) - ret = [] - for term in terms: - if isinstance(term, (list, tuple)): - ret.extend( - self._recursive_flatten(term) - ) - else: - ret.append(term) - return ret - - def run(self, terms, variables=None, **kwargs): - - results = [] - - keys = self._recursive_flatten(terms[0]) - keysPatterns = terms[1] - repositories = terms[2] - - itemDefault = {} - - # Handle repositories defined as reversed preferences - for repository in repositories[::-1]: - if 'key' in repository: - keys.insert(0, repository.get('key')) - - for key in keys: - - items = [] - - item = itemDefault.copy() - - # Short syntax - if isinstance(key, string_types): - item.update( - keysPatterns.get(key) - ) - else: - # Must be a dict - if not isinstance(key, dict): - raise AnsibleError('Expect a dict but was a %s' % type(key)) - - # Check id key - if 'id' not in key: - raise AnsibleError('Expect "id" key') - - item.update(key) - - items.append(item) - - # Merge by index key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['id'] == item['id']: - results[i] = item - itemFound = True - break - - if not itemFound: - results.append(item) - - return results diff --git a/roles/apt/lookup_plugins/manala_apt_packages.py b/roles/apt/lookup_plugins/manala_apt_packages.py deleted file mode 100644 index 989b075b0..000000000 --- a/roles/apt/lookup_plugins/manala_apt_packages.py +++ /dev/null @@ -1,102 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.module_utils.six import string_types -from ansible.errors import AnsibleError -from ansible.module_utils._text import to_text - - -class LookupModule(LookupBase): - - def _recursive_flatten(self, terms): - if not isinstance(terms, list): - raise AnsibleError('Expect a list but was a %s' % type(terms)) - ret = [] - for term in terms: - if isinstance(term, (list, tuple)): - ret.extend( - self._recursive_flatten(term) - ) - else: - ret.append(term) - return ret - - def run(self, terms, variables=None, **kwargs): - - results = [] - - packages = self._recursive_flatten(terms[0]) - - groups = [] - - itemDefault = { - 'state': 'present', - 'deb': False - } - - for package in packages: - - items = [] - - item = itemDefault.copy() - - # Short syntax - if isinstance(package, string_types): - item.update({ - 'package': package - }) - else: - - # Must be a dict - if not isinstance(package, dict): - raise AnsibleError('Expect a dict but was a %s' % type(package)) - - # Check index key - if 'package' not in package: - raise AnsibleError('Expect "package" key') - - item.update(package) - - if item['state'] not in ['present', 'absent', 'ignore']: - raise AnsibleError('Expect a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) - - if item['state'] == 'ignore': - continue - - # Is a .deb ? - if item.get('package').endswith('.deb'): - item.update({ - 'deb': True - }) - - items.append(item) - - # Merge by index key - for item in items: - itemFound = False - for i, group in enumerate(groups): - if group['package'] == item['package']: - groups[i] = item - itemFound = True - break - - if not itemFound: - groups.append(item) - - # Groups - for group in groups: - # Deb packages could only be installed one by one - if group['deb']: - results.append(group) - else: - # If package share the previous one state, group them - if results and not results[-1]['deb'] and group['state'] == results[-1]['state']: - results[-1]['package'].append(group['package']) - else: - group.update({ - 'package': [group['package']] - }) - results.append(group) - - return results diff --git a/roles/apt/lookup_plugins/manala_apt_preferences.py b/roles/apt/lookup_plugins/manala_apt_preferences.py deleted file mode 100644 index e5e31280b..000000000 --- a/roles/apt/lookup_plugins/manala_apt_preferences.py +++ /dev/null @@ -1,158 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.module_utils.six import string_types -from ansible.errors import AnsibleError -from ansible.module_utils._text import to_text - -import os -import re - - -class LookupModule(LookupBase): - - def _recursive_flatten(self, terms): - if not isinstance(terms, list): - raise AnsibleError('Expect a list but was a %s' % type(terms)) - ret = [] - for term in terms: - if isinstance(term, (list, tuple)): - ret.extend( - self._recursive_flatten(term) - ) - else: - ret.append(term) - return ret - - def run(self, terms, variables=None, **kwargs): - - results = [] - - wantstate = kwargs.pop('wantstate', None) - - if wantstate and wantstate not in ['present', 'absent']: - raise AnsibleError('Expect a wanstate of "present" or "absent" but was "%s"' % to_text(wantstate)) - - preferences = self._recursive_flatten(terms[0]) - preferencesPatterns = terms[1] - repositoriesPatterns = terms[2] - exclusives = self._flatten(terms[3]) - dir = terms[4] - template = terms[5] - - itemDefault = { - 'state': 'present', - 'template': template - } - - # Mark exclusive preferences as absent - for preference in exclusives: - item = itemDefault.copy() - item.update({ - 'file': preference['path'], - 'state': 'absent' - }) - results.append(item) - - for preference in preferences: - - items = [] - - item = itemDefault.copy() - - # Short syntax - if isinstance(preference, string_types): - item.update({ - 'preference': preference - }) - else: - # Must be a dict - if not isinstance(preference, dict): - raise AnsibleError('Expect a dict but was a %s' % type(preference)) - - item.update(preference) - - if item['state'] not in ['present', 'absent', 'ignore']: - raise AnsibleError('Expect a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) - - if item['state'] == 'ignore': - continue - - if 'preference' in item: - pattern = item['preference'] - preferencePattern = pattern.split('@')[0] - if 'file' not in item: - item.update({ - 'file': preferencePattern - .split(':')[0] - .replace('.', '_') - }) - if 'package' not in item: - item.update({ - 'package': preferencesPatterns.get( - preferencePattern, - (preferencePattern) - if len(pattern.split('@')) > 1 else - ('*') - ) - }) - if 'pin' not in item: - repositoryPattern = ( - (pattern.split('@')[1]) - if len(pattern.split('@')) > 1 else - (pattern) - ).split(':')[0] - if repositoryPattern not in repositoriesPatterns: - raise AnsibleError('unable to find "%s" repository pattern' % repositoryPattern) - item.update({ - 'pin': repositoriesPatterns - .get(repositoryPattern) - .get( - 'pin', - 'origin ' + re.sub( - 'deb (\\[.+\\] )?https?:\\/\\/([^\\/ ]+)[\\/ ].*$', - '\\2', - repositoriesPatterns - .get(repositoryPattern) - .get('source') - ) - ), - 'repository': repositoryPattern - }) - if 'priority' not in item: - item.update({ - 'priority': int( - (pattern.split(':')[1]) - if len(pattern.split(':')) > 1 else - (900) - ) - }) - - # Check index key - if 'file' not in item: - raise AnsibleError('Expect "file" key') - - item.update({ - 'file': os.path.join(dir, item['file']) - }) - - items.append(item) - - # Merge by index key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['file'] == item['file']: - results[i] = item - itemFound = True - break - - if not itemFound: - results.append(item) - - # Filter by state - if wantstate: - results = [result for result in results if result.get('state') == wantstate] - - return results diff --git a/roles/apt/lookup_plugins/manala_apt_repositories.py b/roles/apt/lookup_plugins/manala_apt_repositories.py deleted file mode 100644 index 992ccc1ef..000000000 --- a/roles/apt/lookup_plugins/manala_apt_repositories.py +++ /dev/null @@ -1,137 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.module_utils.six import string_types -from ansible.errors import AnsibleError -from ansible.module_utils._text import to_text - -import os -import re - - -class LookupModule(LookupBase): - - def _recursive_flatten(self, terms): - if not isinstance(terms, list): - raise AnsibleError('Expect a list but was a %s' % type(terms)) - ret = [] - for term in terms: - if isinstance(term, (list, tuple)): - ret.extend( - self._recursive_flatten(term) - ) - else: - ret.append(term) - return ret - - def run(self, terms, variables=None, **kwargs): - - results = [] - - wantstate = kwargs.pop('wantstate', None) - - if wantstate and wantstate not in ['present', 'absent']: - raise AnsibleError('Expect a wanstate of "present" or "absent" but was "%s"' % to_text(wantstate)) - - repositories = self._recursive_flatten(terms[0]) - repositoriesPatterns = terms[1] - preferences = terms[2] - exclusives = self._flatten(terms[3]) - dir = '/etc/apt/sources.list.d' - - itemDefault = { - 'state': 'present' - } - - # Mark exclusive repositories as absent - for repository in exclusives: - item = itemDefault.copy() - item.update({ - 'file': repository['path'], - 'state': 'absent' - }) - results.append(item) - - # Handle repositories defined as reversed preferences - for preference in preferences[::-1]: - if 'repository' in preference: - repositories.insert(0, preference['repository']) - - for repository in repositories: - - items = [] - - item = itemDefault.copy() - - # Short syntax - if isinstance(repository, string_types): - item.update( - repositoriesPatterns.get(repository) - ) - else: - # Must be a dict - if not isinstance(repository, dict): - raise AnsibleError('Expect a dict but was a %s' % type(repository)) - - if 'pattern' in repository: - item.update( - repositoriesPatterns.get(repository.get('pattern')) - ) - - item.update(repository) - - if item['state'] not in ['present', 'absent', 'ignore']: - raise AnsibleError('Expect a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) - - if item['state'] == 'ignore': - continue - - # Check index key - if 'source' not in item: - raise AnsibleError('Expect "source" key') - - # Force file if not present - if 'file' not in item: - item.update({ - 'file': os.path.join( - dir, - re.sub( - '^deb (\\[.+\\] )?https?:\\/\\/([^ ]+)[ ].*$', - '\\2', - item['source'] - ) - .strip('/ ') - .replace('.', '_') - .replace('/', '_') - .replace('-', '_') - + '.list' - ) - }) - else: - item.update({ - 'file': os.path.join( - dir, - item['file'] - ) - }) - - items.append(item) - - # Merge by index key - for item in items: - itemFound = False - for i, result in enumerate(results): - if ('source' in result and result['source'] == item['source']) or (result['file'] == item['file']): - results[i] = item - itemFound = True - break - - if not itemFound: - results.append(item) - - # Filter by state - if wantstate: - results = [result for result in results if result.get('state') == wantstate] - - return results diff --git a/roles/apt/lookup_plugins/manala_templates_exclusive.py b/roles/apt/lookup_plugins/manala_templates_exclusive.py deleted file mode 100644 index ff57727f0..000000000 --- a/roles/apt/lookup_plugins/manala_templates_exclusive.py +++ /dev/null @@ -1,103 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.errors import AnsibleError -from ansible.module_utils._text import to_text - -import os - - -class LookupModule(LookupBase): - - def _recursive_flatten(self, terms): - if not isinstance(terms, list): - raise AnsibleError('Expect a list but was a %s' % type(terms)) - ret = [] - for term in terms: - if isinstance(term, (list, tuple)): - ret.extend( - self._recursive_flatten(term) - ) - else: - ret.append(term) - return ret - - def run(self, terms, variables=None, **kwargs): - - results = [] - - wantstate = kwargs.pop('wantstate', None) - - if wantstate and wantstate not in ['present', 'absent']: - raise AnsibleError('Expect a wanstate of "present" or "absent" but was "%s"' % to_text(wantstate)) - - templates = self._recursive_flatten(terms[0]) - exclusives = self._flatten(terms[1]) - dir = terms[2] - template = terms[3] - - itemDefault = { - 'state': 'present', - 'template': template - } - - # Mark exclusive templates as absent - for template in exclusives: - item = itemDefault.copy() - item.update({ - 'file': template['path'], - 'state': 'absent' - }) - results.append(item) - - for template in templates: - - items = [] - - # Must be a dict - if not isinstance(template, dict): - raise AnsibleError('Expect a dict but was a %s' % type(template)) - - # Check file key - if 'file' not in template: - # File name based on template - if 'template' in template: - template['file'] = os.path.splitext( - os.path.basename(template['template']) - )[0] - else: - raise AnsibleError('Expect a "file" key') - - item = itemDefault.copy() - item.update(template) - - if item['state'] not in ['present', 'absent', 'ignore']: - raise AnsibleError('Expect a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) - - if item['state'] == 'ignore': - continue - - item.update({ - 'file': os.path.join(dir, item['file']) - }) - - items.append(item) - - # Merge by file key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['file'] == item['file']: - results[i] = item - itemFound = True - break - - if not itemFound: - results.append(item) - - # Filter by state - if wantstate: - results = [result for result in results if result.get('state') == wantstate] - - return results diff --git a/roles/apt/meta/main.yml b/roles/apt/meta/main.yml index 87feae708..831c43417 100644 --- a/roles/apt/meta/main.yml +++ b/roles/apt/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: apt - author: Manala - company: Manala - description: Handle apt - license: MIT - min_ansible_version: 2.5.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: apt + author: Manala + company: Manala + description: Handle apt + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - apt diff --git a/roles/apt/tasks/configs.yml b/roles/apt/tasks/configs.yml index 3c5c737c6..f60c34841 100644 --- a/roles/apt/tasks/configs.yml +++ b/roles/apt/tasks/configs.yml @@ -1,17 +1,9 @@ --- -- name: configs > Directory - file: - path: "{{ manala_apt_configs_dir }}" - state: directory - owner: root - group: root - mode: "0755" - when: manala_apt_configs|length - - name: configs > Exclusive find: path: "{{ manala_apt_configs_dir }}" + file_type: file patterns: "*" changed_when: false register: __manala_apt_configs_exclusive_find @@ -25,25 +17,23 @@ group: root mode: "0644" loop: "{{ query( - 'manala_templates_exclusive', - manala_apt_configs, - __manala_apt_configs_exclusive_find.files|default([]), - manala_apt_configs_dir, - manala_apt_configs_defaults.template|default('configs/_default.j2', true), - wantstate='present' - ) - }}" + 'manala.roles.templates_exclusive', + manala_apt_configs, + __manala_apt_configs_exclusive_find.files|default([]), + manala_apt_configs_dir, + manala_apt_configs_defaults.template|default('configs/_default.j2', true), + wantstate='present' + ) }}" - name: configs > Files absent file: path: "{{ item.file }}" state: absent loop: "{{ query( - 'manala_templates_exclusive', - manala_apt_configs, - __manala_apt_configs_exclusive_find.files|default([]), - manala_apt_configs_dir, - manala_apt_configs_defaults.template|default('configs/_default.j2', true), - wantstate='absent' - ) - }}" + 'manala.roles.templates_exclusive', + manala_apt_configs, + __manala_apt_configs_exclusive_find.files|default([]), + manala_apt_configs_dir, + manala_apt_configs_defaults.template|default('configs/_default.j2', true), + wantstate='absent' + ) }}" diff --git a/roles/apt/tasks/holds.yml b/roles/apt/tasks/holds.yml index 2cae7027c..6121f0026 100644 --- a/roles/apt/tasks/holds.yml +++ b/roles/apt/tasks/holds.yml @@ -12,8 +12,7 @@ name: "{{ item.package }}" selection: "{{ (item.state == 'present')|ternary('hold', 'install') }}" loop: "{{ query( - 'manala_apt_holds', - manala_apt_holds, - __manala_apt_holds_exclusive_find.stdout_lines|default([]), - ) - }}" + 'manala.roles.apt_holds', + manala_apt_holds, + __manala_apt_holds_exclusive_find.stdout_lines|default([]), + ) }}" diff --git a/roles/apt/tasks/install.yml b/roles/apt/tasks/install.yml index d763255bc..3593c8a19 100644 --- a/roles/apt/tasks/install.yml +++ b/roles/apt/tasks/install.yml @@ -2,7 +2,9 @@ - name: install > Packages apt: - name: "{{ manala_apt_install_packages|default(manala_apt_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: "{{ manala_apt_cache_valid_time }}" + loop: + - "{{ manala_apt_install_packages|default(manala_apt_install_packages_default, True) }}" diff --git a/roles/apt/tasks/keys.yml b/roles/apt/tasks/keys.yml index fea302dbf..b2bed5ff6 100644 --- a/roles/apt/tasks/keys.yml +++ b/roles/apt/tasks/keys.yml @@ -8,25 +8,24 @@ validate_certs: "{{ item.validate_certs|default(omit) }}" state: "{{ item.state|default('present') }}" loop: "{{ query( - 'manala_apt_keys', - manala_apt_keys, - manala_apt_keys_patterns, + 'manala.roles.apt_keys', + manala_apt_keys, + manala_apt_keys_patterns, + query( + 'manala.roles.apt_repositories', + manala_apt_repositories, + manala_apt_repositories_patterns, query( - 'manala_apt_repositories', - manala_apt_repositories, - manala_apt_repositories_patterns, - query( - 'manala_apt_preferences', - manala_apt_preferences, - manala_apt_preferences_patterns, - manala_apt_repositories_patterns, - [], - manala_apt_preferences_dir, - manala_apt_preferences_defaults.template|default('preferences/_default.j2', true), - wantstate='present' - ), - [], - wantstate='present' + 'manala.roles.apt_preferences', + manala_apt_preferences, + manala_apt_preferences_patterns, + manala_apt_repositories_patterns, + [], + manala_apt_preferences_dir, + manala_apt_preferences_defaults.template|default('preferences/_default.j2', true), + wantstate='present' ), - ) - }}" + [], + wantstate='present' + ), + ) }}" diff --git a/roles/apt/tasks/packages.yml b/roles/apt/tasks/packages.yml index 8224dbb47..fc026a181 100644 --- a/roles/apt/tasks/packages.yml +++ b/roles/apt/tasks/packages.yml @@ -13,10 +13,9 @@ purge: true autoremove: true loop: "{{ query( - 'manala_apt_packages', - manala_apt_packages, - wantstate='present', - wantmap=True, - wantdeb=True, - ) - }}" + 'manala.roles.apt_packages', + manala_apt_packages, + wantstate='present', + wantmap=True, + wantdeb=True, + ) }}" diff --git a/roles/apt/tasks/preferences.yml b/roles/apt/tasks/preferences.yml index d6f4ba5a1..abfdd9742 100644 --- a/roles/apt/tasks/preferences.yml +++ b/roles/apt/tasks/preferences.yml @@ -1,16 +1,10 @@ --- -- name: preferences > Directory - file: - path: "{{ manala_apt_preferences_dir }}" - state: directory - owner: root - group: root - mode: "0755" - - name: preferences > Exclusive find: path: "{{ manala_apt_preferences_dir }}" + file_type: file + patterns: "*" changed_when: false register: __manala_apt_preferences_exclusive_find when: manala_apt_preferences_exclusive @@ -23,29 +17,27 @@ group: root mode: "0644" loop: "{{ query( - 'manala_apt_preferences', - manala_apt_preferences, - manala_apt_preferences_patterns, - manala_apt_repositories_patterns, - __manala_apt_preferences_exclusive_find.files|default([]), - manala_apt_preferences_dir, - manala_apt_preferences_defaults.template|default('preferences/_default.j2', true), - wantstate='present' - ) - }}" + 'manala.roles.apt_preferences', + manala_apt_preferences, + manala_apt_preferences_patterns, + manala_apt_repositories_patterns, + __manala_apt_preferences_exclusive_find.files|default([]), + manala_apt_preferences_dir, + manala_apt_preferences_defaults.template|default('preferences/_default.j2', true), + wantstate='present' + ) }}" - name: preferences > Files absents file: path: "{{ item.file }}" state: absent loop: "{{ query( - 'manala_apt_preferences', - manala_apt_preferences, - manala_apt_preferences_patterns, - manala_apt_repositories_patterns, - __manala_apt_preferences_exclusive_find.files|default([]), - manala_apt_preferences_dir, - manala_apt_preferences_defaults.template|default('preferences/_default.j2', true), - wantstate='absent' - ) - }}" + 'manala.roles.apt_preferences', + manala_apt_preferences, + manala_apt_preferences_patterns, + manala_apt_repositories_patterns, + __manala_apt_preferences_exclusive_find.files|default([]), + manala_apt_preferences_dir, + manala_apt_preferences_defaults.template|default('preferences/_default.j2', true), + wantstate='absent' + ) }}" diff --git a/roles/apt/tasks/repositories.yml b/roles/apt/tasks/repositories.yml index c504fb4e3..15fa00aed 100644 --- a/roles/apt/tasks/repositories.yml +++ b/roles/apt/tasks/repositories.yml @@ -3,6 +3,7 @@ - name: repositories > Exclusive find: path: /etc/apt/sources.list.d + file_type: file patterns: "*.list" changed_when: false register: __manala_apt_repositories_exclusive_find @@ -15,23 +16,22 @@ update_cache: false mode: "0644" loop: "{{ query( - 'manala_apt_repositories', - manala_apt_repositories, - manala_apt_repositories_patterns, - query( - 'manala_apt_preferences', - manala_apt_preferences, - manala_apt_preferences_patterns, - manala_apt_repositories_patterns, - [], - manala_apt_preferences_dir, - manala_apt_preferences_defaults.template|default('preferences/_default.j2', true), - wantstate='present' - ), - __manala_apt_repositories_exclusive_find.files|default([]), - wantstate='present' - ) - }}" + 'manala.roles.apt_repositories', + manala_apt_repositories, + manala_apt_repositories_patterns, + query( + 'manala.roles.apt_preferences', + manala_apt_preferences, + manala_apt_preferences_patterns, + manala_apt_repositories_patterns, + [], + manala_apt_preferences_dir, + manala_apt_preferences_defaults.template|default('preferences/_default.j2', true), + wantstate='present' + ), + __manala_apt_repositories_exclusive_find.files|default([]), + wantstate='present' + ) }}" register: __manala_apt_repositories_presents_results - name: repositories > Repositories absents @@ -39,26 +39,26 @@ path: "{{ item.file }}" state: absent loop: "{{ query( - 'manala_apt_repositories', - manala_apt_repositories, - manala_apt_repositories_patterns, - query( - 'manala_apt_preferences', - manala_apt_preferences, - manala_apt_preferences_patterns, - manala_apt_repositories_patterns, - [], - manala_apt_preferences_dir, - manala_apt_preferences_defaults.template|default('preferences/_default.j2', true), - wantstate='present' - ), - __manala_apt_repositories_exclusive_find.files|default([]), - wantstate='absent' - ) - }}" + 'manala.roles.apt_repositories', + manala_apt_repositories, + manala_apt_repositories_patterns, + query( + 'manala.roles.apt_preferences', + manala_apt_preferences, + manala_apt_preferences_patterns, + manala_apt_repositories_patterns, + [], + manala_apt_preferences_dir, + manala_apt_preferences_defaults.template|default('preferences/_default.j2', true), + wantstate='present' + ), + __manala_apt_repositories_exclusive_find.files|default([]), + wantstate='absent' + ) }}" register: __manala_apt_repositories_absents_results -- name: repositories > Update cache +- name: repositories > Update cache # noqa no-handler apt: update_cache: true - when: __manala_apt_repositories_presents_results is changed or __manala_apt_repositories_absents_results is changed + when: __manala_apt_repositories_presents_results is changed + or __manala_apt_repositories_absents_results is changed diff --git a/roles/apt/tasks/sources_list.yml b/roles/apt/tasks/sources_list.yml index f9412142d..5f6819a15 100644 --- a/roles/apt/tasks/sources_list.yml +++ b/roles/apt/tasks/sources_list.yml @@ -8,4 +8,4 @@ group: root mode: "0644" when: manala_apt_sources_list_template - or manala_apt_sources_list + or manala_apt_sources_list diff --git a/roles/apt/tasks/update.yml b/roles/apt/tasks/update.yml index 9528b708e..936487a5b 100644 --- a/roles/apt/tasks/update.yml +++ b/roles/apt/tasks/update.yml @@ -1,26 +1,43 @@ --- -- name: update > Backup package marks - shell: "dpkg --get-selections {{ item }} | cut -f 2- | tr -d '\t'" # noqa 306 - with_items: "{{ manala_apt_update_holds }}" - when: manala_apt_update_holds|length +- name: update > Backup package marks # noqa risky-shell-pipe no-tabs + shell: > + dpkg --get-selections {{ item }} + | cut -f 2- + | tr -d '\t' + changed_when: false + loop: "{{ manala_apt_update_holds }}" register: __manala_apt_update_marks_results -- name: update > Hold packages - shell: "echo '{{ item.0 }} hold' | dpkg --set-selections" # noqa 306 - when: item.1 and item.1 != 'hold' - with_together: - - "{{ manala_apt_update_holds }}" - - "{{ __manala_apt_update_marks_results.results|map(attribute='stdout')|list }}" +- name: update > Hold packages # noqa risky-shell-pipe + shell: > + echo '{{ item.0 }} hold' + | dpkg --set-selections + when: + - item.1 + - item.1 != 'hold' + loop: "{{ + manala_apt_update_holds + | zip( + __manala_apt_update_marks_results.results|map(attribute='stdout')|list + ) + | list + }}" - name: update > Upgrade dist apt: upgrade: dist update_cache: true -- name: update > Restore package marks - shell: "echo '{{ item.0 }} {{ item.1 }}' | dpkg --set-selections" # noqa 306 +- name: update > Restore package marks # noqa risky-shell-pipe + shell: > + echo '{{ item.0 }} {{ item.1 }}' + | dpkg --set-selections when: item.1 - with_together: - - "{{ manala_apt_update_holds }}" - - "{{ __manala_apt_update_marks_results.results|map(attribute='stdout')|list }}" + loop: "{{ + manala_apt_update_holds + | zip( + __manala_apt_update_marks_results.results|map(attribute='stdout')|list + ) + | list + }}" diff --git a/roles/apt/templates/configs/_default.j2 b/roles/apt/templates/configs/_default.j2 index 69c2bca05..8b3c321af 100644 --- a/roles/apt/templates/configs/_default.j2 +++ b/roles/apt/templates/configs/_default.j2 @@ -1,14 +1,3 @@ -{%- import '_macros.j2' as macros with context -%} +{%- set config = item.config|default('') -%} -{% set config = item.config|default('') -%} - -{%- if config is iterable and config is not string -%} - -{#- Deprecated -#} -{{- macros.config(config) -}} - -{%- else -%} - -{{ config }} - -{%- endif -%} +{{- config -}} diff --git a/roles/apt/templates/configs/_macros.j2 b/roles/apt/templates/configs/_macros.j2 deleted file mode 100644 index 7e3c4d928..000000000 --- a/roles/apt/templates/configs/_macros.j2 +++ /dev/null @@ -1,66 +0,0 @@ -{#- Deprecated -#} - -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ ('"' ~ parameter ~ '";')|indent(indent, true) }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }}{{ '\n' }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default|indent(indent, true) }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {%- if value is sequence and value is not string -%} - {{ _config_parameter_key(key)|indent(indent, true) }} {{ '{\n' }}{{ config(value, [], indent + 2) }}{{ '};'|indent(indent, true) }} - {%- else -%} - {{ _config_parameter_key(key)|indent(indent, true) }} {{ _config_parameter_value(value) }}; - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - {{ key }} -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {%- if value is sameas none -%} - {%- elif value is sameas true -%} - "true" - {%- elif value is sameas false -%} - "false" - {%- elif value is string -%} - "{{ value }}" - {%- elif value is number -%} - "{{ value }}" - {%- endif -%} -{%- endmacro -%} diff --git a/roles/apt/templates/configs/check_valid_until_false.j2 b/roles/apt/templates/configs/check_valid_until_false.j2 deleted file mode 100644 index c1498a6d3..000000000 --- a/roles/apt/templates/configs/check_valid_until_false.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -Acquire::Check-Valid-Until "false"; diff --git a/roles/apt/templates/sources_list/_default.j2 b/roles/apt/templates/sources_list/_default.j2 index 2ea91785f..3ede156d6 100644 --- a/roles/apt/templates/sources_list/_default.j2 +++ b/roles/apt/templates/sources_list/_default.j2 @@ -1,14 +1,3 @@ {%- set config = manala_apt_sources_list -%} -{%- if config is iterable and config is not string -%} - -{#- Deprecated -#} -{%- import '_macros.j2' as macros with context -%} - -{{ macros.config(config) }} - -{%- else -%} - -{{ config }} - -{%- endif -%} +{{- config -}} diff --git a/roles/apt/templates/sources_list/_macros.j2 b/roles/apt/templates/sources_list/_macros.j2 deleted file mode 100644 index 23ce29e83..000000000 --- a/roles/apt/templates/sources_list/_macros.j2 +++ /dev/null @@ -1,27 +0,0 @@ -{#- Deprecated -#} - -{%- macro config(parameters, exclusions = []) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value) }}{{ '\n' }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value) -%} - {{ _config_parameter_key(key) }} {{ _config_parameter_value(value) }} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - {{ key }} -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {{ value }} -{%- endmacro -%} diff --git a/roles/apt/templates/sources_list/debian.j2 b/roles/apt/templates/sources_list/debian.j2 deleted file mode 100644 index 05e7b7214..000000000 --- a/roles/apt/templates/sources_list/debian.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include 'debian/default.j2' %} diff --git a/roles/apt/templates/sources_list/debian/default.j2 b/roles/apt/templates/sources_list/debian/default.j2 deleted file mode 100644 index f0cfd60ae..000000000 --- a/roles/apt/templates/sources_list/debian/default.j2 +++ /dev/null @@ -1,8 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_apt_sources_list|default([], true) -%} - -deb http://deb.debian.org/debian {{ ansible_distribution_release }} {{ manala_apt_components|flatten|join(' ') }} -{{ macros.config(config) }} diff --git a/roles/apt/templates/sources_list/debian/default_src.j2 b/roles/apt/templates/sources_list/debian/default_src.j2 deleted file mode 100644 index ec3fd2e14..000000000 --- a/roles/apt/templates/sources_list/debian/default_src.j2 +++ /dev/null @@ -1,9 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_apt_sources_list|default([], true) -%} - -deb http://deb.debian.org/debian {{ ansible_distribution_release }} {{ manala_apt_components|flatten|join(' ') }} -deb-src http://deb.debian.org/debian {{ ansible_distribution_release }} {{ manala_apt_components|flatten|join(' ') }} -{{ macros.config(config) }} diff --git a/roles/apt/templates/sources_list/debian/security_updates.j2 b/roles/apt/templates/sources_list/debian/security_updates.j2 deleted file mode 100644 index c9f45d670..000000000 --- a/roles/apt/templates/sources_list/debian/security_updates.j2 +++ /dev/null @@ -1,12 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_apt_sources_list|default([], true) -%} - -deb http://deb.debian.org/debian {{ ansible_distribution_release }} {{ manala_apt_components|flatten|join(' ') }} -{% if ansible_distribution_release not in ['jessie'] -%} -deb http://deb.debian.org/debian {{ ansible_distribution_release }}-updates {{ manala_apt_components|flatten|join(' ') }} -{% endif %} -deb http://security.debian.org/debian-security {{ ansible_distribution_release }}/updates {{ manala_apt_components|flatten|join(' ') }} -{{ macros.config(config) }} diff --git a/roles/apt/templates/sources_list/debian/security_updates_ovh.j2 b/roles/apt/templates/sources_list/debian/security_updates_ovh.j2 deleted file mode 100644 index e7bf53a45..000000000 --- a/roles/apt/templates/sources_list/debian/security_updates_ovh.j2 +++ /dev/null @@ -1,12 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_apt_sources_list|default([], true) -%} - -deb http://debian.mirrors.ovh.net/debian {{ ansible_distribution_release }} {{ manala_apt_components|flatten|join(' ') }} -{% if ansible_distribution_release not in ['jessie'] -%} -deb http://debian.mirrors.ovh.net/debian {{ ansible_distribution_release }}-updates {{ manala_apt_components|flatten|join(' ') }} -{% endif %} -deb http://debian.mirrors.ovh.net/debian-security {{ ansible_distribution_release }}/updates {{ manala_apt_components|flatten|join(' ') }} -{{ macros.config(config) }} diff --git a/roles/apt/templates/sources_list/debian_security_updates.j2 b/roles/apt/templates/sources_list/debian_security_updates.j2 deleted file mode 100644 index 282fb2f7e..000000000 --- a/roles/apt/templates/sources_list/debian_security_updates.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include 'debian/security_updates.j2' %} diff --git a/roles/apt/templates/sources_list/debian_security_updates_ovh.j2 b/roles/apt/templates/sources_list/debian_security_updates_ovh.j2 deleted file mode 100644 index 1eb11f986..000000000 --- a/roles/apt/templates/sources_list/debian_security_updates_ovh.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include 'debian/security_updates_ovh.j2' %} diff --git a/roles/apt/templates/sources_list/debian_src.j2 b/roles/apt/templates/sources_list/debian_src.j2 deleted file mode 100644 index 55b41194e..000000000 --- a/roles/apt/templates/sources_list/debian_src.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include 'debian/default_src.j2' %} diff --git a/roles/apt/templates/sources_list/default.j2 b/roles/apt/templates/sources_list/default.j2 deleted file mode 100644 index 8c16b48e4..000000000 --- a/roles/apt/templates/sources_list/default.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include (ansible_lsb.id|default(ansible_distribution))|lower ~ '/default.j2' %} diff --git a/roles/apt/templates/sources_list/default_src.j2 b/roles/apt/templates/sources_list/default_src.j2 deleted file mode 100644 index 4be093f84..000000000 --- a/roles/apt/templates/sources_list/default_src.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include (ansible_lsb.id|default(ansible_distribution))|lower ~ '/default_src.j2' %} diff --git a/roles/apt/templates/sources_list/raspbian/default.j2 b/roles/apt/templates/sources_list/raspbian/default.j2 deleted file mode 100644 index b667142f0..000000000 --- a/roles/apt/templates/sources_list/raspbian/default.j2 +++ /dev/null @@ -1,8 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_apt_sources_list|default([], true) -%} - -deb http://raspbian.raspberrypi.org/raspbian/ {{ ansible_distribution_release }} {{ manala_apt_components|flatten|join(' ') }} rpi -{{ macros.config(config) }} \ No newline at end of file diff --git a/roles/apt/templates/sources_list/security_updates.j2 b/roles/apt/templates/sources_list/security_updates.j2 deleted file mode 100644 index b5c7d56b1..000000000 --- a/roles/apt/templates/sources_list/security_updates.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include (ansible_lsb.id|default(ansible_distribution))|lower ~ '/security_updates.j2' %} diff --git a/roles/apt/templates/sources_list/security_updates_ovh.j2 b/roles/apt/templates/sources_list/security_updates_ovh.j2 deleted file mode 100644 index 8110a36f1..000000000 --- a/roles/apt/templates/sources_list/security_updates_ovh.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include ansible_distribution|lower ~ '/security_updates_ovh.j2' %} diff --git a/roles/apt/tests/.gitignore b/roles/apt/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/apt/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/apt/tests/0100_configs.goss.yml b/roles/apt/tests/0100_configs.goss.yml deleted file mode 100644 index 73071a5e6..000000000 --- a/roles/apt/tests/0100_configs.goss.yml +++ /dev/null @@ -1,135 +0,0 @@ ---- - -# Default -{{ if has "default" .Vars.tags }} -file: - tmp/configs/default: - exists: true - filetype: directory - owner: root - group: root - mode: "0755" - tmp/configs/default/default_deprecated: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Acquire::Check-Valid-Until \"true\";" - - "APT {" - - " Get {" - - " Assume-Yes \"true\";" - - " Fix-Broken \"false\";" - - " Proxy \"ftp://proxy:2121/\";" - - " SuggestsImportant \"42\";" - - " };" - - " NeverAutoRemove {" - - " \"^firmware-linux.*\";" - - " \"^linux-firmware$\";" - - " };" - - "};" - tmp/configs/default/default_content: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Acquire::Check-Valid-Until \"true\";" - - "APT {" - - " Get {" - - " Assume-Yes \"true\";" - - " Fix-Broken \"false\";" - - " Proxy \"ftp://proxy:2121/\";" - - " SuggestsImportant \"42\";" - - " };" - - " NeverAutoRemove {" - - " \"^firmware-linux.*\";" - - " \"^linux-firmware$\";" - - " };" - - "};" - tmp/configs/default/template: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Configs foo" -{{ end }} - -# State -{{ if has "state" .Vars.tags }} -file: - tmp/configs/state/foo: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - size: 1 - tmp/configs/state/bar: - exists: false - tmp/configs/state/baz: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - size: 1 - tmp/configs/state/qux: - exists: true - filetype: file - tmp/configs/state/quux: - exists: false -{{ end }} - -# Defaults -{{ if has "defaults" .Vars.tags }} -file: - tmp/configs/defaults/foo: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Configs foo" - tmp/configs/defaults/bar: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Configs bar" - tmp/configs/defaults/baz: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Configs bar" -{{ end }} - -# Exclusive -{{ if has "exclusive" .Vars.tags }} -file: - tmp/configs/exclusive/foo: - exists: false - tmp/configs/exclusive/bar: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - size: 1 - tmp/configs/exclusive/baz: - exists: false - tmp/configs/exclusive/qux: - exists: false - tmp/configs/exclusive/quux: - exists: false -{{ end }} diff --git a/roles/apt/tests/0100_configs.yml b/roles/apt/tests/0100_configs.yml deleted file mode 100644 index e396b0aa0..000000000 --- a/roles/apt/tests/0100_configs.yml +++ /dev/null @@ -1,139 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - # Default - - tags: [default] - block: - - file: - path: tmp/configs/default - state: absent - - import_role: - name: manala.apt - tasks_from: configs - vars: - manala_apt_configs_dir: tmp/configs/default - manala_apt_configs: - # Default - Deprecated - - file: default_deprecated - config: - - Acquire::Check-Valid-Until: true - - APT: - - Get: - - Assume-Yes: true - - Fix-Broken: false - - Proxy: ftp://proxy:2121/ - - SuggestsImportant: 42 - - NeverAutoRemove: - - ^firmware-linux.* - - ^linux-firmware$ - # Default - Content - - file: default_content - config: | - Acquire::Check-Valid-Until "true"; - APT { - Get { - Assume-Yes "true"; - Fix-Broken "false"; - Proxy "ftp://proxy:2121/"; - SuggestsImportant "42"; - }; - NeverAutoRemove { - "^firmware-linux.*"; - "^linux-firmware$"; - }; - }; - # Flatten - - - # Template - - file: template - template: configs/foo.j2 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [default]}" validate - - # State - - tags: [state] - block: - - file: - path: tmp/configs/state - state: "{{ item }}" - loop: [absent, directory] - - file: - path: tmp/configs/state/{{ item }} - state: touch - loop: [bar, qux] - - import_role: - name: manala.apt - tasks_from: configs - vars: - manala_apt_configs_dir: tmp/configs/state - manala_apt_configs: - - file: foo - - file: bar - state: absent - - file: baz - state: present - - file: qux - state: ignore - - file: quux - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [state]}" validate - - # Defaults - - tags: [defaults] - block: - - file: - path: tmp/configs/defaults - state: absent - - import_role: - name: manala.apt - tasks_from: configs - vars: - manala_apt_configs_dir: tmp/configs/defaults - manala_apt_configs_defaults: - template: configs/foo.j2 - manala_apt_configs: - - file: foo - - template: configs/bar.j2 - - file: baz - template: configs/bar.j2 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [defaults]}" validate - - # Exclusive - - tags: [exclusive] - block: - - file: - path: tmp/configs/exclusive - state: "{{ item }}" - loop: [absent, directory] - - file: - path: tmp/configs/exclusive/{{ item }} - state: touch - loop: [foo, bar, baz, qux] - - import_role: - name: manala.apt - tasks_from: configs - vars: - manala_apt_configs_dir: tmp/configs/exclusive - manala_apt_configs_exclusive: true - manala_apt_configs: - - file: bar - - file: qux - state: ignore - - file: quux - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [exclusive]}" validate diff --git a/roles/apt/tests/0300_sources_list.goss.yml b/roles/apt/tests/0300_sources_list.goss.yml deleted file mode 100644 index 7cc83c70d..000000000 --- a/roles/apt/tests/0300_sources_list.goss.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- - -file: - tmp/sources_list/default/default_deprecated.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb http://deb.debian.org/debian {{ .Env.DISTRIBUTION_RELEASE }} main" - - "deb http://security.debian.org/debian-security {{ .Env.DISTRIBUTION_RELEASE }}/updates main" - - "deb http://deb.debian.org/debian {{ .Env.DISTRIBUTION_RELEASE }}-updates main" - tmp/sources_list/default/default_content.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb http://deb.debian.org/debian {{ .Env.DISTRIBUTION_RELEASE }} main" - - "deb http://security.debian.org/debian-security {{ .Env.DISTRIBUTION_RELEASE }}/updates main" - - "deb http://deb.debian.org/debian {{ .Env.DISTRIBUTION_RELEASE }}-updates main" - tmp/sources_list/default/template.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Sources list foo" - tmp/sources_list/default/template_deprecated.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb http://deb.debian.org/debian {{ .Env.DISTRIBUTION_RELEASE }} main" - {{ if not (.Env.DISTRIBUTION_RELEASE | regexMatch "jessie") }} - - "deb http://deb.debian.org/debian {{ .Env.DISTRIBUTION_RELEASE }}-updates main" - {{ end }} - - "deb http://security.debian.org/debian-security {{ .Env.DISTRIBUTION_RELEASE }}/updates main" diff --git a/roles/apt/tests/0300_sources_list.yml b/roles/apt/tests/0300_sources_list.yml deleted file mode 100644 index 4510185db..000000000 --- a/roles/apt/tests/0300_sources_list.yml +++ /dev/null @@ -1,54 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - file: - path: tmp/sources_list/default - state: "{{ item }}" - loop: [absent, directory] - # Default - Deprecated - - import_role: - name: manala.apt - tasks_from: sources_list - vars: - manala_apt_sources_list_file: tmp/sources_list/default/default_deprecated.list - manala_apt_sources_list: - - deb: http://deb.debian.org/debian {{ ansible_distribution_release }} main - - deb: http://security.debian.org/debian-security {{ ansible_distribution_release }}/updates main - - deb: http://deb.debian.org/debian {{ ansible_distribution_release }}-updates main - # Default - Content - - import_role: - name: manala.apt - tasks_from: sources_list - vars: - manala_apt_sources_list_file: tmp/sources_list/default/default_content.list - manala_apt_sources_list: | - deb http://deb.debian.org/debian {{ ansible_distribution_release }} main - deb http://security.debian.org/debian-security {{ ansible_distribution_release }}/updates main - deb http://deb.debian.org/debian {{ ansible_distribution_release }}-updates main - # Template - - import_role: - name: manala.apt - tasks_from: sources_list - vars: - manala_apt_sources_list_file: tmp/sources_list/default/template.list - manala_apt_sources_list_template: sources_list/foo.j2 - # Template - Deprecated - - import_role: - name: manala.apt - tasks_from: sources_list - vars: - manala_apt_sources_list_file: tmp/sources_list/default/template_deprecated.list - manala_apt_sources_list_template: sources_list/security_updates.j2 - manala_apt_components: - # Flatten - - - - main - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/apt/tests/0400_preferences.goss.yml b/roles/apt/tests/0400_preferences.goss.yml deleted file mode 100644 index f3a3084c4..000000000 --- a/roles/apt/tests/0400_preferences.goss.yml +++ /dev/null @@ -1,231 +0,0 @@ ---- - -# Default -{{ if has "default" .Vars.tags }} -file: - tmp/preferences/default: - exists: true - filetype: directory - owner: root - group: root - mode: "0755" -{{ if eq .Env.DISTRIBUTION_RELEASE "jessie" "stretch" }} - tmp/preferences/default/dotdeb: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: *" - - "Pin: origin packages.dotdeb.org" - - "Pin-Priority: 200" - tmp/preferences/default/php: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: php-* php5-* php5.6-* php7.0-* php7.1-* php7.2-* php7.3-* php7.4-* php8.0-*" - - "Pin: origin packages.dotdeb.org" - - "Pin-Priority: 300" -{{ else }} - tmp/preferences/default/sury_php: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: *" - - "Pin: origin packages.sury.org" - - "Pin-Priority: 200" - tmp/preferences/default/php: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: php-* php5-* php5.6-* php7.0-* php7.1-* php7.2-* php7.3-* php7.4-* php8.0-*" - - "Pin: origin packages.sury.org" - - "Pin-Priority: 300" -{{ end }} - tmp/preferences/default/git: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: git git-*" - - "Pin: release a={{ .Env.DISTRIBUTION_RELEASE }}-backports" - - "Pin-Priority: 900" - tmp/preferences/default/libssl1_0_0: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: libssl1.0.0" - - "Pin: release a={{ .Env.DISTRIBUTION_RELEASE }}-backports" - - "Pin-Priority: 900" - tmp/preferences/default/ansible: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: ansible*" - - "Pin: origin ppa.launchpad.net" - - "Pin-Priority: 900" - tmp/preferences/default/ansible_foo: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: ansible*" - - "Pin: origin ppa.launchpad.net" - - "Pin-Priority: 900" - tmp/preferences/default/ansible_bar: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: foo bar" - - "Pin: origin ppa.launchpad.net" - - "Pin-Priority: 900" - tmp/preferences/default/ansible_baz: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: ansible*" - - "Pin: baz" - - "Pin-Priority: 900" - tmp/preferences/default/ansible_qux: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: ansible*" - - "Pin: origin ppa.launchpad.net" - - "Pin-Priority: 1234" - tmp/preferences/default/foo_foo: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: foo" - - "Pin: foo" - - "Pin-Priority: 100" - tmp/preferences/default/foo_template: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Preference foo" - tmp/preferences/default/bar_bar: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: bar" - - "Pin: bar" - - "Pin-Priority: 100" - tmp/preferences/default/baz_baz: - exists: false -{{ end }} - -# State -{{ if has "state" .Vars.tags }} -file: - tmp/preferences/state/foo: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: foo" - - "Pin: foo" - - "Pin-Priority: 100" - tmp/preferences/state/bar: - exists: false - tmp/preferences/state/baz: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: baz" - - "Pin: baz" - - "Pin-Priority: 100" - tmp/preferences/state/qux: - exists: true - filetype: file - tmp/preferences/state/quux: - exists: false -{{ end }} - -# Defaults -{{ if has "defaults" .Vars.tags }} -file: - tmp/preferences/defaults/foo: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Preference foo" - tmp/preferences/defaults/bar: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Preference bar" -{{ end }} - -# Exclusive -{{ if has "exclusive" .Vars.tags }} -file: - tmp/preferences/exclusive/foo: - exists: false - tmp/preferences/exclusive/bar: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Package: bar" - - "Pin: bar" - - "Pin-Priority: 100" - tmp/preferences/exclusive/baz: - exists: false - tmp/preferences/exclusive/qux: - exists: false - tmp/preferences/exclusive/quux: - exists: false -{{ end }} diff --git a/roles/apt/tests/0400_preferences.yml b/roles/apt/tests/0400_preferences.yml deleted file mode 100644 index b83e0b619..000000000 --- a/roles/apt/tests/0400_preferences.yml +++ /dev/null @@ -1,178 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - tags: [always] - block: - # Jessie repositories have been archived, meaning that some of them - # (backports, for instance) will remain invalid forever. - - copy: - dest: /etc/apt/apt.conf.d/archive - content: | - Acquire::Check-Valid-Until "false"; - when: ansible_distribution_release in ['jessie'] - - # Default - - tags: [default] - block: - - file: - path: tmp/preferences/default - state: absent - - import_role: - name: manala.apt - tasks_from: preferences - vars: - manala_apt_preferences_dir: tmp/preferences/default - manala_apt_preferences: - # Short syntax - - git@backports - - libssl1.0.0@backports - - "{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('php@dotdeb:300','php@sury_php:300') }}" - - "{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('dotdeb:100','sury_php:100') }}" - - "{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('dotdeb:200','sury_php:200') }}" - # Pattern syntax - - preference: ansible@ansible - - preference: ansible@ansible - file: ansible_foo - - preference: ansible@ansible - file: ansible_bar - package: foo bar* - - preference: ansible@ansible - file: ansible_baz - pin: baz - - preference: ansible@ansible - file: ansible_qux - priority: 1234 - # Verbose syntax - - package: foo - pin: foo - priority: 100 - file: foo_foo - # Flatten - - - # Template - - file: foo_template - template: preferences/foo.j2 - # States - - package: bar - pin: bar - priority: 100 - file: bar_bar - state: present - - package: baz - pin: baz - priority: 100 - file: baz_baz - state: absent - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [default]}" validate - - # State - - tags: [state] - block: - - file: - path: tmp/preferences/state - state: "{{ item }}" - loop: [absent, directory] - - file: - path: tmp/preferences/state/{{ item }} - state: touch - loop: [bar, qux] - - import_role: - name: manala.apt - tasks_from: preferences - vars: - manala_apt_preferences_dir: tmp/preferences/state - manala_apt_preferences: - - package: foo - pin: foo - priority: 100 - file: foo - - package: bar - pin: bar - priority: 100 - file: bar - state: absent - - package: baz - pin: baz - priority: 100 - file: baz - state: present - - package: qux - pin: qux - priority: 100 - file: qux - state: ignore - - package: quux - pin: quux - priority: 100 - file: quux - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [state]}" validate - - # Defaults - - tags: [defaults] - block: - - file: - path: tmp/preferences/defaults - state: absent - - import_role: - name: manala.apt - tasks_from: preferences - vars: - manala_apt_preferences_dir: tmp/preferences/defaults - manala_apt_preferences_defaults: - template: preferences/foo.j2 - manala_apt_preferences: - - file: foo - - file: bar - template: preferences/bar.j2 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [defaults]}" validate - - # Exclusive - - tags: [exclusive] - block: - - file: - path: tmp/preferences/exclusive - state: "{{ item }}" - loop: [absent, directory] - - file: - path: tmp/preferences/exclusive/{{ item }} - state: touch - loop: [foo, bar, baz, qux] - - import_role: - name: manala.apt - tasks_from: preferences - vars: - manala_apt_preferences_dir: tmp/preferences/exclusive - manala_apt_preferences_exclusive: true - manala_apt_preferences: - - package: bar - pin: bar - priority: 100 - file: bar - - package: qux - pin: qux - priority: 100 - file: qux - state: ignore - - package: quux - pin: quux - priority: 100 - file: quux - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [exclusive]}" validate diff --git a/roles/apt/tests/0500_keys.goss.yml b/roles/apt/tests/0500_keys.goss.yml deleted file mode 100644 index 51d840f2d..000000000 --- a/roles/apt/tests/0500_keys.goss.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- - -command: - "apt-key adv --list-public-keys --with-colons | grep '^pub' | cut -d':' -f 5 | egrep -o '.{8}$'": - exit-status: 0 - stdout: -{{ if eq .Env.DISTRIBUTION_RELEASE "jessie" "stretch" }} - - 89DF5277 # Dotdeb -{{ else }} - - 95BD4743 # Sury_php -{{ end }} - - 65558117 # Multimedia - - 7BD9BF62 # Nginx - - 86E50310 # Yarn - - ACCC4CF8 # PostgreSQL - - EB9C94BB # Sensu - - 65558117 # Multimedia - - 056E8E56 # RabbitMQ - - BC19DDBA # Galera diff --git a/roles/apt/tests/0500_keys.yml b/roles/apt/tests/0500_keys.yml deleted file mode 100644 index f7dc4435a..000000000 --- a/roles/apt/tests/0500_keys.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_role: - # Play role fully, because of "preferences" and "repositories" tasks dependency - name: manala.apt - vars: - manala_apt_preferences_exclusive: true - manala_apt_preferences: - - "{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('dotdeb:100', 'sury_php:100') }}" - - preference: avidemux@multimedia - manala_apt_repositories_exclusive: true - manala_apt_repositories: - - security - - nginx - - source: deb https://dl.yarnpkg.com/debian/ stable main - key: yarn - - source: deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main - key: - url: https://www.postgresql.org/media/keys/ACCC4CF8.asc - id: ACCC4CF8 - manala_apt_keys: - - sensu - - multimedia - # Flatten - - - - url: http://www.rabbitmq.com/rabbitmq-signing-key-public.asc - id: 056E8E56 - - keyserver: keyserver.ubuntu.com - id: BC19DDBA - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/apt/tests/0600_repositories.goss.yml b/roles/apt/tests/0600_repositories.goss.yml deleted file mode 100644 index a363f8f18..000000000 --- a/roles/apt/tests/0600_repositories.goss.yml +++ /dev/null @@ -1,207 +0,0 @@ ---- - -# Default -{{ if has "default" .Vars.tags }} -file: - # From preferences -{{ if eq .Env.DISTRIBUTION_RELEASE "jessie" }} - /etc/apt/sources.list.d/archive_debian_org_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb http://archive.debian.org/debian {{ .Env.DISTRIBUTION_RELEASE }}-backports main" -{{ else }} - /etc/apt/sources.list.d/deb_debian_org_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb http://deb.debian.org/debian {{ .Env.DISTRIBUTION_RELEASE }}-backports main" -{{ end }} -/etc/apt/sources.list.d/multimedia.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb http://www.deb-multimedia.org {{ .Env.DISTRIBUTION_RELEASE }} main" -{{ if eq .Env.DISTRIBUTION_RELEASE "jessie" "stretch" }} - /etc/apt/sources.list.d/dotdeb.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb http://packages.dotdeb.org {{ .Env.DISTRIBUTION_RELEASE }} all" - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_1_10_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb https://downloads.mariadb.com/MaxScale/2.1.10/debian {{ .Env.DISTRIBUTION_RELEASE }} main" - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_1_11_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb https://downloads.mariadb.com/MaxScale/2.1.11/debian {{ .Env.DISTRIBUTION_RELEASE }} main" - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_1_12_debian.list: - exists: false -{{ else }} - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_3_10_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb https://downloads.mariadb.com/MaxScale/2.3.10/debian {{ .Env.DISTRIBUTION_RELEASE }} main" - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_3_11_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb https://downloads.mariadb.com/MaxScale/2.3.11/debian {{ .Env.DISTRIBUTION_RELEASE }} main" - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_3_12_debian.list: - exists: false -{{ end }} - /etc/apt/sources.list.d/nginx_org_packages_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb http://nginx.org/packages/debian/ {{ .Env.DISTRIBUTION_RELEASE }} nginx" - /etc/apt/sources.list.d/dl_yarnpkg_com_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb https://dl.yarnpkg.com/debian/ stable main" - /etc/apt/sources.list.d/apt_postgresql_org_pub_repos_apt.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb http://apt.postgresql.org/pub/repos/apt/ {{ .Env.DISTRIBUTION_RELEASE }}-pgdg main" - /etc/apt/sources.list.d/packages_grafana_com_oss_deb.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb https://packages.grafana.com/oss/deb stable main" -{{ end }} - -# State -{{ if has "state" .Vars.tags }} -file: -{{ if eq .Env.DISTRIBUTION_RELEASE "jessie" "stretch" }} - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_2_1_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb https://downloads.mariadb.com/MaxScale/2.2.1/debian {{ .Env.DISTRIBUTION_RELEASE }} main" - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_2_2_debian.list: - exists: false - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_2_3_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb https://downloads.mariadb.com/MaxScale/2.2.3/debian {{ .Env.DISTRIBUTION_RELEASE }} main" - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_2_4_debian.list: - exists: true - filetype: file - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_2_5_debian.list: - exists: false -{{ else }} - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_4_1_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb https://downloads.mariadb.com/MaxScale/2.4.1/debian {{ .Env.DISTRIBUTION_RELEASE }} main" - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_4_2_debian.list: - exists: false - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_4_3_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb https://downloads.mariadb.com/MaxScale/2.4.3/debian {{ .Env.DISTRIBUTION_RELEASE }} main" - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_4_4_debian.list: - exists: true - filetype: file - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_4_5_debian.list: - exists: false -{{ end }} -{{ end }} - -# Exclusive -{{ if has "exclusive" .Vars.tags }} -file: -{{ if eq .Env.DISTRIBUTION_RELEASE "jessie" "stretch" }} - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_2_6_debian.list: - exists: false - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_2_7_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb https://downloads.mariadb.com/MaxScale/2.2.7/debian {{ .Env.DISTRIBUTION_RELEASE }} main" - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_2_9_debian.list: - exists: false - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_2_10_debian.list: - exists: false - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_2_11_debian.list: - exists: false -{{ else }} - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_4_6_debian.list: - exists: false - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_4_7_debian.list: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "deb https://downloads.mariadb.com/MaxScale/2.4.7/debian {{ .Env.DISTRIBUTION_RELEASE }} main" - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_4_9_debian.list: - exists: false - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_4_10_debian.list: - exists: false - /etc/apt/sources.list.d/downloads_mariadb_com_MaxScale_2_4_11_debian.list: - exists: false -{{ end }} -{{ end }} diff --git a/roles/apt/tests/0600_repositories.yml b/roles/apt/tests/0600_repositories.yml deleted file mode 100644 index 5300085e6..000000000 --- a/roles/apt/tests/0600_repositories.yml +++ /dev/null @@ -1,120 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - tags: [always] - block: - # Jessie repositories have been archived, meaning that some of them - # (backports, for instance) will remain invalid forever. - - copy: - dest: /etc/apt/apt.conf.d/archive - content: | - Acquire::Check-Valid-Until "false"; - when: ansible_distribution_release in ['jessie'] - - # Default - - tags: [default] - block: - - import_role: - # Play role fully, because of "preferences" tasks dependency - name: manala.apt - vars: - manala_apt_preferences: - - git@backports - - libssl1.0.0@backports - - "{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('php@dotdeb:300','php@sury_php:300') }}" - - "{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('dotdeb:100','sury_php:100') }}" - - "{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('dotdeb:200','sury_php:200') }}" - - preference: avidemux@multimedia - manala_apt_repositories: - - backports - - nginx - - source: deb https://dl.yarnpkg.com/debian/ stable main - key: yarn - - source: deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main - key: - url: https://www.postgresql.org/media/keys/ACCC4CF8.asc - id: ACCC4CF8 - - pattern: grafana - # Flatten - - - - source: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.1.10', '2.3.10') }}/debian {{ ansible_distribution_release }} main - key: maxscale - - source: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.1.11', '2.3.11') }}/debian {{ ansible_distribution_release }} main - key: maxscale - state: present - - source: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.1.12', '2.3.12') }}/debian {{ ansible_distribution_release }} main - key: maxscale - state: absent - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [default]}" validate - - # State - - tags: [state] - block: - - apt_key: - url: https://downloads.mariadb.com/MaxScale/old_key.public - id: 8167EE24 - - apt_key: - keyserver: hkp://keyserver.ubuntu.com:80 - id: 28C12247 - - apt_repository: - repo: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.2', '2.4.2') }}/debian {{ ansible_distribution_release }} main - - apt_repository: - repo: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.4', '2.4.4') }}/debian {{ ansible_distribution_release }} main - - import_role: - name: manala.apt - tasks_from: repositories - vars: - manala_apt_repositories: - - source: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.1', '2.4.1') }}/debian {{ ansible_distribution_release }} main - - source: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.2', '2.4.2') }}/debian {{ ansible_distribution_release }} main - state: absent - - source: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.3', '2.4.3') }}/debian {{ ansible_distribution_release }} main - state: present - - source: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.4', '2.4.4') }}/debian {{ ansible_distribution_release }} main - state: ignore - - source: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.5', '2.4.5') }}/debian {{ ansible_distribution_release }} main - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [state]}" validate - - # Exclusive - - tags: [exclusive] - block: - - apt_key: - url: https://downloads.mariadb.com/MaxScale/old_key.public - id: 8167EE24 - - apt_key: - keyserver: hkp://keyserver.ubuntu.com:80 - id: 28C12247 - - apt_repository: - repo: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.6', '2.4.6') }}/debian {{ ansible_distribution_release }} main - - apt_repository: - repo: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.7', '2.4.7') }}/debian {{ ansible_distribution_release }} main - - apt_repository: - repo: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.9', '2.4.9') }}/debian {{ ansible_distribution_release }} main - - apt_repository: - repo: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.10', '2.4.10') }}/debian {{ ansible_distribution_release }} main - - import_role: - name: manala.apt - tasks_from: repositories - vars: - manala_apt_repositories_exclusive: true - manala_apt_repositories: - - source: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.7', '2.4.7') }}/debian {{ ansible_distribution_release }} main - - source: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.10', '2.4.10') }}/debian {{ ansible_distribution_release }} main - state: ignore - - source: deb https://downloads.mariadb.com/MaxScale/{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('2.2.11', '2.4.11') }}/debian {{ ansible_distribution_release }} main - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [exclusive]}" validate diff --git a/roles/apt/tests/0700_packages.goss.yml b/roles/apt/tests/0700_packages.goss.yml deleted file mode 100644 index f44c72ff0..000000000 --- a/roles/apt/tests/0700_packages.goss.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- - -{{ if has "default" .Vars.tags }} -package: - asciijump: - installed: true - freesweep: - installed: true - an: - installed: false - spinner: - installed: true - versions: - - 1.2.4-3 - wait-for-it: - installed: true - pscan: - installed: false -{{ end }} - -# State -{{ if has "state" .Vars.tags }} -package: - asciijump: - installed: true - an: - installed: false - freesweep: - installed: true - nettoe: - installed: true - wordplay: - installed: false -{{ end }} diff --git a/roles/apt/tests/0700_packages.yml b/roles/apt/tests/0700_packages.yml deleted file mode 100644 index cc0d193bb..000000000 --- a/roles/apt/tests/0700_packages.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - # Default - - tags: [default] - block: - - apt: - name: - - asciijump - - freesweep - state: absent - - apt: - name: - - an - install_recommends: false - - apt: - deb: http://snapshot.debian.org/archive/debian-archive/20120328T092752Z/debian/pool/main/p/pscan/pscan_1.2-9_amd64.deb - - import_role: - name: manala.apt - tasks_from: packages - vars: - manala_apt_packages: - - asciijump - - package: freesweep - state: absent - - package: freesweep - state: present - - package: an - state: absent - # Flatten - - - - http://snapshot.debian.org/archive/debian/20111228T033508Z/pool/main/s/spinner/spinner_1.2.4-3_amd64.deb - - package: http://snapshot.debian.org/archive/debian/20160619T164515Z/pool/main/w/wait-for-it/wait-for-it_0.0~git20160501-1_all.deb - state: present - - package: pscan - state: absent - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [default]}" validate - - # State - - tags: [state] - block: - - apt: - name: - - asciijump - - freesweep - - wordplay - state: absent - - apt: - name: - - an - - nettoe - install_recommends: false - - file: - path: tmp/configs/state/{{ item }} - state: touch - loop: [bar, qux] - - import_role: - name: manala.apt - tasks_from: packages - vars: - manala_apt_packages: - - asciijump - - package: an - state: absent - - package: freesweep - state: present - - package: nettoe - state: ignore - - package: wordplay - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [state]}" validate diff --git a/roles/apt/tests/0800_holds.goss.yml b/roles/apt/tests/0800_holds.goss.yml deleted file mode 100644 index c135be6cf..000000000 --- a/roles/apt/tests/0800_holds.goss.yml +++ /dev/null @@ -1,40 +0,0 @@ ---- - -# Default -{{ if has "default" .Vars.tags }} -command: - apt-mark showhold: - exit-status: 0 - stdout: - - apt - - dpkg - - "!python" - - grep - - "!tar" -{{ end }} - -# Hold -{{ if has "hold" .Vars.tags }} -command: - apt-mark showhold: - exit-status: 0 - stdout: - - apt - - "!dpkg" - - python - - grep - - "!tar" -{{ end }} - -# Exclusive -{{ if has "exclusive" .Vars.tags }} -command: - apt-mark showhold: - exit-status: 0 - stdout: - - "!apt" - - dpkg - - "!python" - - "!grep" - - "!tar" -{{ end }} diff --git a/roles/apt/tests/0800_holds.yml b/roles/apt/tests/0800_holds.yml deleted file mode 100644 index 82aa965b9..000000000 --- a/roles/apt/tests/0800_holds.yml +++ /dev/null @@ -1,94 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - # Default - - tags: [default] - block: - - dpkg_selections: - name: "{{ item }}" - selection: install - loop: [apt, dpkg, grep] - - dpkg_selections: - name: "{{ item }}" - selection: hold - loop: [python, tar] - - import_role: - name: manala.apt - tasks_from: holds - vars: - manala_apt_holds: - # Short syntax - - apt - # Flatten - - - # States - - package: dpkg - state: present - - package: python - state: absent - # Deprecated - - package: grep - hold: true - - package: tar - hold: false - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [default]}" validate - - # State - - tags: [state] - block: - - dpkg_selections: - name: "{{ item }}" - selection: install - loop: [apt, python, tar] - - dpkg_selections: - name: "{{ item }}" - selection: hold - loop: [dpkg, grep] - - import_role: - name: manala.apt - tasks_from: holds - vars: - manala_apt_holds: - - package: apt - - package: dpkg - state: absent - - package: python - state: present - - package: grep - state: ignore - - package: tar - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [hold]}" validate - - # Exclusive - - tags: [exclusive] - block: - - dpkg_selections: - name: "{{ item }}" - selection: hold - loop: [apt, dpkg, python, grep] - - import_role: - name: manala.apt - tasks_from: holds - vars: - manala_apt_holds_exclusive: true - manala_apt_holds: - - package: dpkg - - package: grep - state: ignore - - package: tar - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [exclusive]}" validate diff --git a/roles/apt/tests/0800_update.yml b/roles/apt/tests/0800_update.yml deleted file mode 100644 index 4ffceaa76..000000000 --- a/roles/apt/tests/0800_update.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_role: - name: manala.apt - tasks_from: update - vars: - manala_apt: - update: true - manala_apt_update_holds: - - foo - - unzip diff --git a/roles/apt/tests/templates/configs/bar.j2 b/roles/apt/tests/templates/configs/bar.j2 deleted file mode 100644 index 53e654354..000000000 --- a/roles/apt/tests/templates/configs/bar.j2 +++ /dev/null @@ -1 +0,0 @@ -Configs bar diff --git a/roles/apt/tests/templates/configs/foo.j2 b/roles/apt/tests/templates/configs/foo.j2 deleted file mode 100644 index cdc34797b..000000000 --- a/roles/apt/tests/templates/configs/foo.j2 +++ /dev/null @@ -1 +0,0 @@ -Configs foo diff --git a/roles/apt/tests/templates/preferences/bar.j2 b/roles/apt/tests/templates/preferences/bar.j2 deleted file mode 100644 index 76e2333f7..000000000 --- a/roles/apt/tests/templates/preferences/bar.j2 +++ /dev/null @@ -1 +0,0 @@ -Preference bar diff --git a/roles/apt/tests/templates/preferences/foo.j2 b/roles/apt/tests/templates/preferences/foo.j2 deleted file mode 100644 index c183bd37c..000000000 --- a/roles/apt/tests/templates/preferences/foo.j2 +++ /dev/null @@ -1 +0,0 @@ -Preference foo diff --git a/roles/apt/tests/templates/sources_list/foo.j2 b/roles/apt/tests/templates/sources_list/foo.j2 deleted file mode 100644 index 358a4f9b8..000000000 --- a/roles/apt/tests/templates/sources_list/foo.j2 +++ /dev/null @@ -1 +0,0 @@ -Sources list foo diff --git a/roles/apt/tests/tmp/.gitignore b/roles/apt/tests/tmp/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/roles/apt/tests/tmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/roles/apt/vars/main.yml b/roles/apt/vars/main.yml index 62998d3e9..68d2d5f44 100644 --- a/roles/apt/vars/main.yml +++ b/roles/apt/vars/main.yml @@ -16,18 +16,24 @@ manala_apt_repositories_patterns: source: deb http://deb.debian.org/debian {{ ansible_distribution_release }} {{ manala_apt_components|flatten|join(' ') }} pin: release a={{ ansible_distribution_release }} security: - source: deb http://security.debian.org/debian-security {{ ansible_distribution_release }}/updates {{ manala_apt_components|flatten|join(' ') }} + source: >- + deb http://security.debian.org/debian-security + {{ ansible_distribution_release }}{{ (ansible_distribution_release in ['stretch', 'buster'])|ternary('/updates', '-security') }} + {{ manala_apt_components|flatten|join(' ') }} security_src: - source: deb-src http://security.debian.org/debian-security {{ ansible_distribution_release }}/updates {{ manala_apt_components|flatten|join(' ') }} + source: >- + deb-src http://security.debian.org/debian-security + {{ ansible_distribution_release }}{{ (ansible_distribution_release in ['stretch', 'buster'])|ternary('/updates', '-security') }} + {{ manala_apt_components|flatten|join(' ') }} updates: source: deb http://deb.debian.org/debian {{ ansible_distribution_release }}-updates {{ manala_apt_components|flatten|join(' ') }} updates_src: source: deb-src http://deb.debian.org/debian {{ ansible_distribution_release }}-updates {{ manala_apt_components|flatten|join(' ') }} backports: - source: deb http://{{ (ansible_distribution_release in ['jessie'])|ternary('archive', 'deb') }}.debian.org/debian {{ ansible_distribution_release }}-backports {{ manala_apt_components|flatten|join(' ') }} + source: deb http://deb.debian.org/debian {{ ansible_distribution_release }}-backports {{ manala_apt_components|flatten|join(' ') }} pin: release a={{ ansible_distribution_release }}-backports backports_sloppy: - source: deb http://{{ (ansible_distribution_release in ['jessie'])|ternary('archive', 'deb') }}.debian.org/debian {{ ansible_distribution_release }}-backports-sloppy {{ manala_apt_components|flatten|join(' ') }} + source: deb http://deb.debian.org/debian {{ ansible_distribution_release }}-backports-sloppy {{ manala_apt_components|flatten|join(' ') }} pin: release a={{ ansible_distribution_release }}-backports-sloppy multimedia: source: deb http://www.deb-multimedia.org {{ ansible_distribution_release }} main @@ -37,44 +43,15 @@ manala_apt_repositories_patterns: source: deb http://www.deb-multimedia.org {{ ansible_distribution_release }}-backports main key: multimedia file: multimedia_backports.list - # Deprecated - debian_security: - source: deb http://security.debian.org/debian-security {{ ansible_distribution_release }}/updates {{ manala_apt_components|flatten|join(' ') }} - # Deprecated - debian_security_src: - source: deb-src http://security.debian.org/debian-security {{ ansible_distribution_release }}/updates {{ manala_apt_components|flatten|join(' ') }} - # Deprecated - debian_updates: - source: deb http://deb.debian.org/debian {{ ansible_distribution_release }}-updates {{ manala_apt_components|flatten|join(' ') }} - # Deprecated - debian_updates_src: - source: deb-src http://deb.debian.org/debian {{ ansible_distribution_release }}-updates {{ manala_apt_components|flatten|join(' ') }} - # Deprecated - debian_backports: - source: deb http://{{ (ansible_distribution_release in ['jessie'])|ternary('archive', 'deb') }}.debian.org/debian {{ ansible_distribution_release }}-backports {{ manala_apt_components|flatten|join(' ') }} - pin: release a={{ ansible_distribution_release }}-backports - dotdeb: - source: deb http://packages.dotdeb.org {{ ansible_distribution_release }} all - key: dotdeb - file: dotdeb.list nginx: source: deb http://nginx.org/packages/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx key: nginx bearstech: source: deb http://deb.bearstech.com/debian {{ ansible_distribution_release }}-bearstech main key: bearstech - nodesource_0_10: - source: deb https://deb.nodesource.com/node_0.10 {{ ansible_distribution_release }} main - key: nodesource - nodesource_0_12: - source: deb https://deb.nodesource.com/node_0.12 {{ ansible_distribution_release }} main - key: nodesource nodesource_4: source: deb https://deb.nodesource.com/node_4.x {{ ansible_distribution_release }} main key: nodesource - nodesource_5: - source: deb https://deb.nodesource.com/node_5.x {{ ansible_distribution_release }} main - key: nodesource nodesource_6: source: deb https://deb.nodesource.com/node_6.x {{ ansible_distribution_release }} main key: nodesource @@ -108,21 +85,18 @@ manala_apt_repositories_patterns: mysql_8_0: source: deb http://repo.mysql.com/apt/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} mysql-8.0 key: mysql - mariadb_10_0: - source: deb http://ftp.osuosl.org/pub/mariadb/repo/10.0/debian {{ ansible_distribution_release }} main - key: mariadb_legacy mariadb_10_1: source: deb http://ftp.osuosl.org/pub/mariadb/repo/10.1/debian {{ ansible_distribution_release }} main - key: "{{ (ansible_distribution_release not in ['jessie'])|ternary('mariadb','mariadb_legacy') }}" + key: mariadb mariadb_10_2: source: deb http://ftp.osuosl.org/pub/mariadb/repo/10.2/debian {{ ansible_distribution_release }} main - key: "{{ (ansible_distribution_release not in ['jessie'])|ternary('mariadb','mariadb_legacy') }}" + key: mariadb mariadb_10_3: source: deb https://downloads.mariadb.com/MariaDB/mariadb-10.3/repo/debian {{ ansible_distribution_release }} main - key: "{{ (ansible_distribution_release not in ['jessie'])|ternary('mariadb','mariadb_legacy') }}" + key: mariadb mariadb_10_4: source: deb https://downloads.mariadb.com/MariaDB/mariadb-10.4/repo/debian {{ ansible_distribution_release }} main - key: "{{ (ansible_distribution_release not in ['jessie'])|ternary('mariadb','mariadb_legacy') }}" + key: mariadb mariadb_10_5: source: deb https://downloads.mariadb.com/MariaDB/mariadb-10.5/repo/debian {{ ansible_distribution_release }} main key: mariadb @@ -132,10 +106,6 @@ manala_apt_repositories_patterns: maxscale_2_2: source: deb https://downloads.mariadb.com/MaxScale/2.2/debian {{ ansible_distribution_release }} main key: maxscale -# Deprecated - Use `maxscale_2_2` - maxscale_2_2_6: - source: deb https://downloads.mariadb.com/MaxScale/2.2.6/debian {{ ansible_distribution_release }} main - key: maxscale maxscale_2_3: source: deb https://downloads.mariadb.com/MaxScale/2.3/debian {{ ansible_distribution_release }} main key: maxscale @@ -178,9 +148,6 @@ manala_apt_repositories_patterns: jenkins: source: deb http://pkg.jenkins-ci.org/debian binary/ key: jenkins - sensu: - source: deb https://sensu.global.ssl.fastly.net/apt {{ ansible_distribution_release }} main - key: sensu sensu-go: source: deb https://packagecloud.io/sensu/stable/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} main key: sensu-go @@ -193,14 +160,11 @@ manala_apt_repositories_patterns: proxmox_enterprise: source: deb https://enterprise.proxmox.com/debian/pve {{ ansible_distribution_release }} pve-enterprise key: proxmox - logentries: - source: deb http://rep.logentries.com/ {{ {'jessie':'jessie', 'stretch':'stretch', 'buster':'bionic'}[ansible_distribution_release] }} main - key: logentries galera_3: - source: deb {{ (ansible_distribution_release not in ['jessie'])|ternary('[trusted=yes] ','') }}http://releases.galeracluster.com/galera-3/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} main + source: deb [trusted=yes] http://releases.galeracluster.com/galera-3/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} main key: galera galera_3_31: - source: deb {{ (ansible_distribution_release not in ['jessie'])|ternary('[trusted=yes] ','') }}http://releases.galeracluster.com/galera-3.31/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} main + source: deb [trusted=yes] http://releases.galeracluster.com/galera-3.31/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} main key: galera galera_4: source: deb https://releases.galeracluster.com/galera-4/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} main @@ -212,10 +176,10 @@ manala_apt_repositories_patterns: source: deb https://releases.galeracluster.com/galera-4.8/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} main key: galera mysql_wsrep_5_6: - source: deb {{ (ansible_distribution_release not in ['jessie'])|ternary('[trusted=yes] ','') }}http://releases.galeracluster.com/mysql-wsrep-5.6/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} main + source: deb [trusted=yes] http://releases.galeracluster.com/mysql-wsrep-5.6/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} main key: galera mysql_wsrep_5_7: - source: deb {{ (ansible_distribution_release not in ['jessie'])|ternary('[trusted=yes] ','') }}http://releases.galeracluster.com/mysql-wsrep-5.7/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} main + source: deb [trusted=yes] http://releases.galeracluster.com/mysql-wsrep-5.7/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} main key: galera mysql_wsrep_8_0: source: deb https://releases.galeracluster.com/mysql-wsrep-8.0/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} main @@ -229,9 +193,6 @@ manala_apt_repositories_patterns: grafana: source: deb https://packages.grafana.com/oss/deb stable main key: grafana - elasticsearch_1_7: - source: deb https://packages.elastic.co/elasticsearch/1.7/debian stable main - key: elasticsearch elasticsearch_2: source: deb https://packages.elastic.co/elasticsearch/2.x/debian stable main key: elasticsearch @@ -245,7 +206,10 @@ manala_apt_repositories_patterns: source: deb https://artifacts.elastic.co/packages/7.x/apt stable main key: elasticsearch ansible: - source: deb http://ppa.launchpad.net/ansible/ansible/ubuntu {{ {'jessie':'trusty', 'stretch':'xenial', 'buster':'bionic'}[ansible_distribution_release] }} main + source: >- + deb http://ppa.launchpad.net/ansible/ansible/ubuntu + {{ {'stretch':'xenial', 'buster':'bionic', 'bullseye':'focal'}[ansible_distribution_release] }} + main key: ansible blackfire: source: deb http://packages.blackfire.io/debian any main @@ -257,7 +221,9 @@ manala_apt_repositories_patterns: source: deb http://repo.aptly.info/ squeeze main key: aptly docker: - source: deb [arch={{ ansible_architecture|manala_apt_architecture }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable + source: >- + deb [arch={{ ansible_architecture|manala.roles.apt_architecture }}] + https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable key: docker manala: source: deb [arch=amd64] http://debian.manala.io {{ ansible_distribution_release }} main @@ -266,7 +232,9 @@ manala_apt_repositories_patterns: source: deb http://apt.newrelic.com/debian/ newrelic non-free key: newrelic newrelic-infra: - source: deb [arch={{ ansible_architecture|manala_apt_architecture }}] https://download.newrelic.com/infrastructure_agent/linux/apt {{ ansible_distribution_release }} main + source: >- + deb [arch={{ ansible_architecture|manala.roles.apt_architecture }}] + https://download.newrelic.com/infrastructure_agent/linux/apt {{ ansible_distribution_release }} main key: newrelic-infra influxdata: source: deb https://repos.influxdata.com/debian {{ ansible_distribution_release }} stable @@ -277,10 +245,6 @@ manala_apt_repositories_patterns: sury_php: source: deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main key: sury_php - # Deprecated - sury_php_debian: - source: deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main - key: sury_php_debian percona: source: deb http://repo.percona.com/apt {{ ansible_distribution_release }} main key: percona @@ -294,13 +258,25 @@ manala_apt_repositories_patterns: source: deb https://obiba.jfrog.io/artifactory/debian-local all main key: mica glusterfs_6: - source: deb https://download.gluster.org/pub/gluster/glusterfs/6/LATEST/Debian/{{ ansible_distribution_release }}/{{ ansible_architecture|manala_apt_architecture }}/apt {{ ansible_distribution_release }} main + source: >- + deb https://download.gluster.org/pub/gluster/glusterfs/6/LATEST/Debian/{{ ansible_distribution_release }}/{{ + ansible_architecture|manala.roles.apt_architecture + }}/apt + {{ ansible_distribution_release }} main key: glusterfs_6 glusterfs_6_1: - source: deb https://download.gluster.org/pub/gluster/glusterfs/6/6.1/Debian/{{ ansible_distribution_release }}/{{ ansible_architecture|manala_apt_architecture }}/apt {{ ansible_distribution_release }} main + source: >- + deb https://download.gluster.org/pub/gluster/glusterfs/6/6.1/Debian/{{ ansible_distribution_release }}/{{ + ansible_architecture|manala.roles.apt_architecture + }}/apt + {{ ansible_distribution_release }} main key: glusterfs_6 glusterfs_6_10: - source: deb https://download.gluster.org/pub/gluster/glusterfs/6/6.10/Debian/{{ ansible_distribution_release }}/{{ ansible_architecture|manala_apt_architecture }}/apt {{ ansible_distribution_release }} main + source: >- + deb https://download.gluster.org/pub/gluster/glusterfs/6/6.10/Debian/{{ ansible_distribution_release }}/{{ + ansible_architecture|manala.roles.apt_architecture + }}/apt + {{ ansible_distribution_release }} main key: glusterfs_6 haproxy_1_8: source: deb http://haproxy.debian.net {{ ansible_distribution_release }}-backports-1.8 main @@ -326,9 +302,6 @@ manala_apt_keys_patterns: multimedia: keyserver: hkp://keyserver.ubuntu.com:80 id: 65558117 - dotdeb: - url: http://www.dotdeb.org/dotdeb.gpg - id: 89DF5277 nginx: url: http://nginx.org/keys/nginx_signing.key id: 7BD9BF62 @@ -341,10 +314,6 @@ manala_apt_keys_patterns: mysql: url: https://repo.mysql.com/RPM-GPG-KEY-mysql id: 5072E1F5 - # Jessie - mariadb_legacy: - url: https://yum.mariadb.org/RPM-GPG-KEY-MariaDB - id: 1BB943DB mariadb: url: https://raw.githubusercontent.com/MariaDB/mariadb.org-tools/master/release/create_package_tarballs/deb_files/MariaDB-C74CD1D8-public.asc id: C74CD1D8 @@ -384,9 +353,6 @@ manala_apt_keys_patterns: jenkins: url: http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key id: D50582E6 - sensu: - url: https://sensu.global.ssl.fastly.net/apt/pubkey.gpg - id: EB9C94BB sensu-go: url: https://packagecloud.io/sensu/stable/gpgkey id: 0A3F7426 @@ -396,9 +362,6 @@ manala_apt_keys_patterns: proxmox: url: http://download.proxmox.com/debian/proxmox-ve-release-5.x.gpg id: E2EF0603 - logentries: - keyserver: hkp://keyserver.ubuntu.com:80 - id: C43C79AD galera: keyserver: hkp://keyserver.ubuntu.com:80 id: BC19DDBA @@ -435,12 +398,8 @@ manala_apt_keys_patterns: sury_php: url: https://packages.sury.org/php/apt.gpg id: 95BD4743 - # Deprecated - sury_php_debian: - url: https://packages.sury.org/php/apt.gpg - id: 95BD4743 percona: - url: https://github.com/percona/percona-repositories/raw/master/deb/percona-keyring2.gpg + url: https://github.com/percona/percona-repositories/raw/main/deb/percona-keyring.gpg id: 8507EFA5 matomo: url: https://debian.matomo.org/repository.gpg @@ -475,58 +434,53 @@ manala_apt_keys_patterns: # Preferences manala_apt_preferences_patterns: - vim: vim* - git: git git-* - php: php-* php5-* php5.6-* php7.0-* php7.1-* php7.2-* php7.3-* php7.4-* php8.0-* php8.1-* - mysql: mysql* libmysql* - nginx: nginx* - ruby: ruby* - nodejs: nodejs* - rabbitmq: rabbitmq* - redis: redis* - logentries: logentries* - sensu: sensu* - haproxy: haproxy* - galera: galera* - grafana: grafana* - elasticsearch: elasticsearch* - postgresql: postgresql* - mongodb: mongodb* - keepalived: keepalived* - gitlab-ce: gitlab-ce* - phpmyadmin: phpmyadmin* - phppgadmin: phppgadmin* - docker: docker* - chrony: chrony* - backup-manager: backup-manager* + vim: vim* + git: git git-* + php: php php-* /^php[1-9]+/ + mysql: mysql* libmysql* + nginx: nginx* + ruby: ruby* + nodejs: nodejs* + rabbitmq: rabbitmq* + redis: redis* + haproxy: haproxy* + galera: galera* + grafana: grafana* + elasticsearch: elasticsearch* + postgresql: postgresql* + mongodb: mongodb* + keepalived: keepalived* + gitlab-ce: gitlab-ce* + docker: docker* + chrony: chrony* + backup-manager: backup-manager* pam-ssh-agent-auth: libpam-ssh-agent-auth* - oauth2-proxy: oauth2-proxy* - cloud: cloud-init cloud-utils - mariadb: mariadb* libmariadb* - maxscale: maxscale* - influxdb: influxdb* - telegraf: telegraf* - thefuck: thefuck* - python-six: python-six* - htop: htop* - yarn: yarn* - openssh: openssh* - ansible: ansible* - openjdk: openjdk-* ca-certificates-java - linux: linux-base linux-image-* linux-headers-* - httpie: httpie* - certbot: certbot python-certbot python-acme python3-certbot python3-acme python-cryptography python-openssl python-setuptools python-pyasn1 python-pkg-resources - thumbor: thumbor python-libthumbor - mica: mica - sensu-go: sensu-go-* - ffmpeg: "ffmpeg {{ + cloud: cloud-init cloud-utils + mariadb: mariadb* libmariadb* + maxscale: maxscale* + influxdb: influxdb* + telegraf: telegraf* + python-six: python-six* + htop: htop* + yarn: yarn* + openssh: openssh* + ansible: ansible* + openjdk: openjdk-* ca-certificates-java + linux: linux-base linux-image-* linux-headers-* + certbot: >- + certbot python-certbot python-acme python3-certbot python3-acme python-cryptography + python-openssl python-setuptools python-pyasn1 python-pkg-resources + thumbor: thumbor python-libthumbor + mica: mica + sensu-go: sensu-go-* + ffmpeg: "ffmpeg {{ { - 'jessie': 'libavcodec56 libva1 libavdevice56 libavfilter5 libavformat56 libavresample2 libavutil54 libpostproc53 libswresample1 libswscale3', 'stretch': 'libavcodec57 libavdevice57 libavfilter6 libavformat57 libavresample3 libavutil55 libpostproc54 libswresample2 libswscale4', - 'buster': 'libavcodec58 libavdevice58 libavfilter7 libavformat58 libavresample4 libavutil56 libpostproc55 libswresample3 libswscale5' + 'buster': 'libavcodec58 libavdevice58 libavfilter7 libavformat58 libavresample4 libavutil56 libpostproc55 libswresample3 libswscale5', + 'bullseye': 'libavcodec58 libavdevice58 libavfilter7 libavformat58 libavresample4 libavutil56 libpostproc55 libswresample3 libswscale5', }[ansible_distribution_release] }}" - glusterfs: glusterfs-* - newrelic-infra: newrelic-infra - filebeat: filebeat* - kopia: kopia* + glusterfs: glusterfs-* + newrelic-infra: newrelic-infra + filebeat: filebeat* + kopia: kopia* diff --git a/roles/aptly/.gitignore b/roles/aptly/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/aptly/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/aptly/.manala/make/Makefile b/roles/aptly/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/aptly/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/aptly/.manala/make/Makefile.docker b/roles/aptly/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/aptly/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/aptly/.manala/make/Makefile.host b/roles/aptly/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/aptly/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/aptly/.manala/make/Makefile.manala b/roles/aptly/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/aptly/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/aptly/.manala/make/Makefile.travis b/roles/aptly/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/aptly/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/aptly/.manala/make/gmsl/__gmsl b/roles/aptly/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/aptly/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/aptly/.manala/make/gmsl/gmsl b/roles/aptly/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/aptly/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/aptly/.travis.yml b/roles/aptly/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/aptly/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/aptly/CHANGELOG.md b/roles/aptly/CHANGELOG.md deleted file mode 100644 index 3df2da2f5..000000000 --- a/roles/aptly/CHANGELOG.md +++ /dev/null @@ -1,55 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.3] - 2021-01-15 -### Added -- Dict based config filters -- Flatten repositories array -- `ignore` repository state - -# Changed -- Deprecate dict's array config - -## [2.0.2] - 2020-08-28 -### Changed -- Explicit file permissions - -## [2.0.1] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.4] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.3] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.2] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support -- Import pre-generated gpg key instead of generate it in tests - -## [1.0.0] - 2017-06-21 -### Added -- Handle installation -- Handle config -- Handle repositories diff --git a/roles/aptly/Makefile b/roles/aptly/Makefile deleted file mode 100644 index 483cbbe8f..000000000 --- a/roles/aptly/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.aptly -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/aptly/README.md b/roles/aptly/README.md index fb267bda4..5e697ff19 100644 --- a/roles/aptly/README.md +++ b/roles/aptly/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Aptly [![Build Status](https://travis-ci.org/manala/ansible-role-aptly.svg?branch=master)](https://travis-ci.org/manala/ansible-role-aptly) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Aptly This role will deal with the setup of [Aptly](https://www.aptly.info/). -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,37 +14,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.aptly -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.aptly -``` - -## Role Handlers - -None. +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -### Definition - -| Name | Default | Type | Description | -| --------------------------------------- | ------------------ | ------------ | -------------------------------------- | -| `manala_aptly_install_packages` | ~ | Array | Dependency packages to install | -| `manala_aptly_install_packages_default` | ['bzip2', 'aptly'] | Array | Default dependency packages to install | -| `manala_aptly_user` | ~ | String | User | -| `manala_aptly_config_file` | '/etc/aptly.conf' | String | Config file path | -| `manala_aptly_config_template` | ~ | String | Config template path | -| `manala_aptly_config` | ~ | Array/String | Config | -| `manala_aptly_repositories` | [] | Array | Collection of repositories | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example @@ -93,14 +55,6 @@ manala_aptly_config: | } ``` -Use dict's array parameters (deprecated): -```yaml -manala_aptly_config: - - rootDir: /tmp/aptly - - architectures: - - amd64 -``` - Repositories: ```yaml @@ -128,13 +82,16 @@ manala_aptly_repositories: ```yaml - hosts: servers - roles: - - role: manala.aptly + tasks: + - import_role: + name: manala.roles.aptly ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/aptly/filter_plugins/.gitignore b/roles/aptly/filter_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/aptly/filter_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/aptly/filter_plugins/manala_json.py b/roles/aptly/filter_plugins/manala_json.py deleted file mode 100644 index 684a446d1..000000000 --- a/roles/aptly/filter_plugins/manala_json.py +++ /dev/null @@ -1,24 +0,0 @@ -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -from ansible.errors import AnsibleFilterError -from ansible.module_utils.six import iteritems, string_types -from ansible.plugins.filter.core import to_nice_json - -def json(parameters, exclude=[]): - if not isinstance(parameters, dict): - raise AnsibleFilterError('manala_json expects a dict but was given a %s' % type(parameters)) - [parameters.pop(key, None) for key in exclude] - result = to_nice_json(parameters) - return result - - -class FilterModule(object): - ''' Manala json jinja2 filters ''' - - def filters(self): - filters = { - 'manala_json': json, - } - - return filters diff --git a/roles/aptly/meta/main.yml b/roles/aptly/meta/main.yml index ee2d6e877..ddbaa0d8b 100644 --- a/roles/aptly/meta/main.yml +++ b/roles/aptly/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: aptly - author: Manala - company: Manala - description: Handle aptly - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: aptly + author: Manala + company: Manala + description: Handle aptly + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - aptly diff --git a/roles/aptly/tasks/config.yml b/roles/aptly/tasks/config.yml index c3f11d3ca..7270a616d 100644 --- a/roles/aptly/tasks/config.yml +++ b/roles/aptly/tasks/config.yml @@ -8,4 +8,4 @@ group: root mode: "0644" when: manala_aptly_config_template - or manala_aptly_config + or manala_aptly_config diff --git a/roles/aptly/tasks/install.yml b/roles/aptly/tasks/install.yml index a0e859e0c..d33bc83e2 100644 --- a/roles/aptly/tasks/install.yml +++ b/roles/aptly/tasks/install.yml @@ -2,7 +2,9 @@ - name: install > Packages apt: - name: "{{ manala_aptly_install_packages|default(manala_aptly_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_aptly_install_packages|default(manala_aptly_install_packages_default, True) }}" diff --git a/roles/aptly/tasks/repositories.yml b/roles/aptly/tasks/repositories.yml index 42bf64f66..90a021461 100644 --- a/roles/aptly/tasks/repositories.yml +++ b/roles/aptly/tasks/repositories.yml @@ -15,6 +15,11 @@ failed_when: false changed_when: false register: __manala_aptly_repositories_find_output + when: | + manala_aptly_repositories + | flatten + | manala.roles.staten(want='present') + | length - name: repositories > Create command: "{{ @@ -29,9 +34,9 @@ }}" when: item.name not in __manala_aptly_repositories_find_output.stdout_lines loop: "{{ - manala_aptly_repositories | flatten | selectattr('state', 'undefined') | list - + - manala_aptly_repositories | flatten | selectattr('state', 'defined') | rejectattr('state', 'equalto', 'ignore') | list + manala_aptly_repositories + | flatten + | manala.roles.staten(want='present') }}" - name: repositories > Publish @@ -43,7 +48,7 @@ }}" when: item.name not in __manala_aptly_repositories_find_output.stdout_lines loop: "{{ - manala_aptly_repositories | flatten | selectattr('state', 'undefined') | list - + - manala_aptly_repositories | flatten | selectattr('state', 'defined') | rejectattr('state', 'equalto', 'ignore') | list + manala_aptly_repositories + | flatten + | manala.roles.staten(want='present') }}" diff --git a/roles/aptly/templates/config/_default.j2 b/roles/aptly/templates/config/_default.j2 index bd539b793..8ed04e8db 100644 --- a/roles/aptly/templates/config/_default.j2 +++ b/roles/aptly/templates/config/_default.j2 @@ -2,15 +2,7 @@ {%- if config is mapping -%} -{{ config | manala_json }} - -{%- elif config is iterable and config is not string -%} - -{#- Deprecated -#} -{%- import '_macros.j2' as macros with context -%} - -{ -{{ macros.config(config, [], 4) }}} +{{ config | manala.roles.json }} {%- else -%} diff --git a/roles/aptly/templates/config/_macros.j2 b/roles/aptly/templates/config/_macros.j2 deleted file mode 100644 index d2d219f95..000000000 --- a/roles/aptly/templates/config/_macros.j2 +++ /dev/null @@ -1,74 +0,0 @@ -{#- Deprecated -#} - -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {% set outer_loop = loop %} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }}{% if not outer_loop.last %},{% endif %}{{ '\n' }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {%- if value is sequence and value is not string -%} - {%- if value[0] is string -%} - {{ _config_parameter_key(key)|indent(indent, true) }}: [ - {%- for data in value -%} - {{ _config_parameter_value(data) }}{% if not loop.last %}, {% endif %} - {%- endfor -%}] - {%- else -%} - {{ ('"' ~ key ~ '"')|indent(indent, true) }}: {{ '{\n' }}{{ config(value, [], indent + 4) }}{{ '}'|indent(indent, true) }} - {%- endif -%} - {%- else -%} - {{ _config_parameter_key(key)|indent(indent, true) }}: {{ _config_parameter_value(value) }} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - "{{ key }}" -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {%- if value is sameas none -%} - {%- elif value is sameas true -%} - true - {%- elif value is sameas false -%} - false - {%- elif value is string -%} - "{{ value }}" - {%- elif value is number -%} - {{ value }} - {%- endif -%} -{%- endmacro -%} diff --git a/roles/aptly/tests/.gitignore b/roles/aptly/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/aptly/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/aptly/tests/0000_default.yml b/roles/aptly/tests/0000_default.yml deleted file mode 100644 index 2a395ff1a..000000000 --- a/roles/aptly/tests/0000_default.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/aptly.yml - - - block: - - import_role: - name: manala.aptly - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/aptly/tests/0200_config.goss.yml b/roles/aptly/tests/0200_config.goss.yml deleted file mode 100644 index 87e8bcf08..000000000 --- a/roles/aptly/tests/0200_config.goss.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- - -file: - tmp/config/default/default.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - '{' - - ' "architectures": [' - - ' "amd64"' - - ' ], ' - - ' "rootDir": "/tmp/aptly"' - - '}' - tmp/config/default/default_deprecated.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - '{' - - ' "rootDir": "/tmp/aptly",' - - ' "architectures": ["amd64"]' - - '}' - tmp/config/default/default_content.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - '{' - - ' "rootDir": "/tmp/aptly",' - - ' "architectures": [' - - ' "amd64"' - - ' ]' - - '}' - tmp/config/default/template.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - Config aptly diff --git a/roles/aptly/tests/0200_config.yml b/roles/aptly/tests/0200_config.yml deleted file mode 100644 index 2ac405ab8..000000000 --- a/roles/aptly/tests/0200_config.yml +++ /dev/null @@ -1,59 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/aptly.yml - - - block: - - file: - path: tmp/config/default - state: "{{ item }}" - loop: [absent, directory] - # Default - - import_role: - # Play role fully on first run, so that handlers don't breaks - name: manala.aptly - vars: - manala_aptly_config_file: tmp/config/default/default.conf - manala_aptly_config: - rootDir: /tmp/aptly - architectures: - - amd64 - # Default - Deprecated - - import_role: - name: manala.aptly - tasks_from: config - vars: - manala_aptly_config_file: tmp/config/default/default_deprecated.conf - manala_aptly_config: - - rootDir: /tmp/aptly - - architectures: - - amd64 - # Default - Content - - import_role: - name: manala.aptly - tasks_from: config - vars: - manala_aptly_config_file: tmp/config/default/default_content.conf - manala_aptly_config: | - { - "rootDir": "/tmp/aptly", - "architectures": [ - "amd64" - ] - } - # Template - - import_role: - name: manala.aptly - tasks_from: config - vars: - manala_aptly_config_file: tmp/config/default/template.conf - manala_aptly_config_template: config/aptly.conf.j2 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/aptly/tests/0300_repositories.goss.yml b/roles/aptly/tests/0300_repositories.goss.yml deleted file mode 100644 index a4335ceba..000000000 --- a/roles/aptly/tests/0300_repositories.goss.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- - -command: - aptly repo list: - exit-status: 0 - stdout: - - " * [bar]: Bar (packages: 0)" - - " * [foo]: Foo (packages: 0)" - aptly repo show foo: - exit-status: 0 - stdout: - - "Name: foo" - - "Comment: Foo" - - "Default Distribution: stretch" - - "Default Component: main" - - "Number of packages: 0" - aptly repo show bar: - exit-status: 0 - stdout: - - "Name: bar" - - "Comment: Bar" - - "Default Distribution: buster" - - "Default Component: main" - - "Number of packages: 0" - -file: - /tmp/aptly/public/dists/buster/Release: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - /tmp/aptly/public/dists/buster/main/binary-amd64/Packages: - exists: true - filetype: file - owner: root - group: root - mode: "0644" diff --git a/roles/aptly/tests/0300_repositories.yml b/roles/aptly/tests/0300_repositories.yml deleted file mode 100644 index 2ed9ffc6d..000000000 --- a/roles/aptly/tests/0300_repositories.yml +++ /dev/null @@ -1,63 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - # See: https://www.aptly.info/doc/feature/pgp-providers/ - - apt: - name: - - gnupg1 - - gpgv1 - install_recommends: false - when: ansible_distribution_release in ['stretch','buster'] - - import_tasks: pre_tasks/aptly.yml - # See: https://www.aptly.info/doc/feature/pgp-providers/ - - block: - - apt: - name: - - gnupg1 - - gpgv1 - install_recommends: false - when: ansible_distribution_release in ['stretch','buster'] - - command: gpg1 --allow-secret-key-import --import {{ playbook_dir }}/fixtures/gpg/private.asc - args: - creates: ~/.gnupg/trustdb.gpg - when: ansible_distribution_release in ['stretch','buster'] - - block: - - command: gpg --allow-secret-key-import --import {{ playbook_dir }}/fixtures/gpg/private.asc - args: - creates: ~/.gnupg/trustdb.gpg - when: ansible_distribution_release not in ['stretch','buster'] - - - block: - - import_role: - name: manala.aptly - vars: - manala_aptly_config: - rootDir: /tmp/aptly - architectures: - - amd64 - manala_aptly_repositories: - - name: ignore - state: ignore - - name: foo - comment: Foo - component: main - distribution: stretch - origin: Foo - label: Foo - # Flatten - - - - name: bar - comment: Bar - component: main - distribution: buster - origin: Bar - label: Bar - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/aptly/tests/pre_tasks/apt_keys/aptly.pgp b/roles/aptly/tests/pre_tasks/apt_keys/aptly.pgp deleted file mode 100644 index b00dbdfef..000000000 --- a/roles/aptly/tests/pre_tasks/apt_keys/aptly.pgp +++ /dev/null @@ -1,52 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- - -mQINBFqq5noBEADD5vEO+RfaGCDpvtFKP4piVF0niHJ4nI52UvCLYa2Yn6dpiUCk -JVa+JL+XbO13nM4tmkzkNKQE1kvisxw3Q6+AZTol849EJqLSTRgxcda5ND4Lakiv -m46FwqQoVcKtcfkPm4uo4SYvaNH4bGPJzqpM5etfhCLmT+6xXA6Ke7PeYk61lh7d -IWxjUJFaljm6+SuElOhYlLFsh/XLx+PemEnoR3jsRTeysoieICfod5X+CEK6JxfZ -9oR5Xl4RS7b7BTUVnOaWYCVOWYvg3/cYdqsdM34thZI474feaNmMgOMULc87HqbK -DwpYTzS1LLcEK1M3qqxk5KdG7vmydhOTI+xSiSLDD3HOsJ+Hy2f9kbFLZ+EpS9z6 -3rVTOROEMkjYxYJ2JwmlFZVGm17CNfEYUM/I0fSkH4c1NoJw0od9M+y1XZM/JV1I -MqnQO75ZWNU+Nta53Lo4dr2Un37FRBaa2RWh/deLOOkzd8uUiA51EKcJj+cEMf2U -FQZ+OZLA4N4PJux68dL6OyN4AOrITCP15ORKgTuj0ttweq0SswfSGVilB+H32sby -ctz8gEmM2FWpo78lja2MN5O6/9v3Nb1kRjCQPqyEyptg5ns3qzUqIumQvasOwqEs -GyEBOrB2M2+a2eLhDDcPHdvxhzMYOqvHm1FHeFI6Wqf9kQx73eknmPN1sQARAQAB -tBxBbmRyZXkgU21pcm5vdiA8bWVAc21pcmEucnU+iQJVBBMBCgA/AhsDBgsJCAcD -AgYVCAIJCgsEFgIDAQIeAQIXgBYhBCbanYYwMC4Lhqeiy+11taRIPaB8BQJeb9Y7 -BQkHh1bBAAoJEO11taRIPaB8TKoP/RxQQd8a5XADWSv2EoqG3duO33RRLSibsmdP -+8e7Uz8GZIwLtmvk8ABiZLftuGaLY4nm0fniSGyDOsCe3wNZGtOmesQXiGyxy9Jp -XqATT4ykuOlV6omSOPPlOsydJ9vbIwhPVKSrnWPsiZphYvEOcMJPvwn7ieoqJB60 -H1urjm3kL/wKjpLIU0lOc18Ak+Ft46srjFXWBuFHwTvGveBnB1im+DXnVZX72Hrl -zUj+/XNMxdWoeep8zVI9hXG77Oi6jBavJLOmlqc5jchM9/ON+MX2uV1OPCI8Du8h -RCe5NZLK17scJO2bite1+awaFtAK7B3g/Yr+ah2/dTesBfAgaaeYonDuANpflL42 -lW4//AKiyipZ6jgcZLUZqnuWo30e3KVgnS5z3yJV0kel4F2Nzro6XyLzkDyxtZvy -Xzlmsq13JUP3wJBDSOPYJO/1lHx9vceY4lPZlINKnpc78y/1GYbLGbwkTmevbvGS -+Oe4cAq9nc+WbY+Y0vd2a7fD59EcCSdwLIjyOQ17J1mQMJ4QP/ItLgQbeTv8uPDS -Bru0845ENS+Zp/pO/oJm4SFR54rqdsfa8RpvAqJuOHmmviE1Lw3nM+sFvRHX2bh5 -msPADHmaISRizRSahFanV12NcHnAGZUW6jMSXUNvRw2Qoud6k6RwxbewFczKmWic -XvvED+nYuQINBFqq5noBEADBGXs/iH6XZKiHcSDcu8snIcZzgoQCHupFzGDdwXMN -+TWr1/XfwjrP2qClQa9jJ5z87Xik2BTxteKJHhL6W8OaAOboiYNHMKxi/R0mLIXl -BCB9MjaaobxvtR9BzyXoe23fGRiR2QGb7cPClxjtSWDCoRK6Uk1MaMHO2Ws/Yt5o -ccAtMMR+8I8SMUw9iJpK0x9pqZM6ckB1QDptOUvFmSZzyn7f/ybQQ7FCCIixdYk5 -+d9KtR+vFHnq60ekWYAHm5ODKXnWxGWah/MYGnw0xCo9eheHZGe2DGyWZMAf+YqU -HUxrZdCfnAloPk0BtUjB6YDKLeSb8QczZmVvxPDbyyjx5Yw4O5cDCy0G4Jjn3XtJ -Y66Csmf0beXKUaxFwlDv8I/XXh0126e/fLbbLdmvMzTf5xComXtlCNSKNL+PKIsp -iW9D3RvJDidKE3KI3TNxE/6670nMhmtEEnNUGRsjHYFwKXX3kNiedA0DMuZb29tN -mXSHfNRA0LCqxDvN9RBVNd7dPoCkKaslAjhVqVgvs3G0XV24RhJECxB+GNTGc8GZ -wfJnMHWcdlfOqDkPAnbnsXR9rWI/rfBlB6CsAYpwyyyL8fNxeMSpAtBmatPybAd8 -gAkNTj53zCYKD2QBCeI3+3M9pYSZuTbzztwF9H19A3Gs0272P+fXFZCjC9UM/4XK -IQARAQABiQI8BBgBCgAmAhsMFiEEJtqdhjAwLguGp6LL7XW1pEg9oHwFAl5v1k4F -CQeHVtQACgkQ7XW1pEg9oHyfuxAAn/1ip9sawaGE4GJLlN62qWrtR/p/z5gHgqzT -YkmjN5rNIVBKqHqMeE5KPhf2C/bB4k3XhEYiJ7akPb2//m2pfoYE76woYXVH66xA -T1G9QoIiHbNOkJKKskCd2jPZZhT2gdYE227C3gizBB+55Nrp9gcqPyT+9LkitOBh -/mMNfRZuj4nDQvd8Kpl6/kyVX/LMF94c1/RzWA3RUx7usNXF8HQKsHLKKGDVN9nY -4kIannF3Fn0xHUWa6sXF42CjnD6hZ45qWUE/J4e5PcP+58OVxlGyHAbqf1L+dQOA -hqTybKpgYW33wrif5Z45Q1vfP9sDcGOd3muV9K/K5ltakhmDs7vQB4RwBljyIzGP -6puW1MwMhREphSHCdVIcKtT8yIoTf/bt9K9KGjp5Xv0x9Rzoh/PbU/zlMyeKEBiV -kmx36fnRpQKtg191xq6y1wW4qNWpdVNzKRepHetwWPfIKY7jSFO3pKBVaunVkLPj -bCrwLjn5YMqmSBUb9faeA2YctWiOhzGAOPDr1HSVW7hOOvxRTTwyBPFFbeepoer5 -tOCBB9gC8Bphi52Euy3qXzq89itbXsbMU56Y+HufdX6AtjQWJ462T91s36d8+/lf -XA0YCIjxH3RYg5WNEpADJecC2PdWsMJDqMhBefu8rYhjUMXPsnvUKjgoxnFaMerz -F4hKkVA= -=0rwG ------END PGP PUBLIC KEY BLOCK----- diff --git a/roles/aptly/tests/pre_tasks/aptly.yml b/roles/aptly/tests/pre_tasks/aptly.yml deleted file mode 100644 index 55f5a049b..000000000 --- a/roles/aptly/tests/pre_tasks/aptly.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- - -- name: Pre tasks > Aptly apt key - apt_key: - file: pre_tasks/apt_keys/aptly.pgp - id: ED75B5A4483DA07C - -- name: Pre tasks > Aptly apt repository - apt_repository: - repo: deb http://repo.aptly.info/ squeeze main - -- name: Pre tasks > Aptly preferences - copy: - dest: /etc/apt/preferences.d/aptly - content: | - Package: aptly* - Pin: origin repo.aptly.info - Pin-Priority: 900 diff --git a/roles/aptly/tests/templates/config/aptly.conf.j2 b/roles/aptly/tests/templates/config/aptly.conf.j2 deleted file mode 100644 index 9f06a9446..000000000 --- a/roles/aptly/tests/templates/config/aptly.conf.j2 +++ /dev/null @@ -1 +0,0 @@ -Config aptly diff --git a/roles/aptly/tests/tmp/.gitignore b/roles/aptly/tests/tmp/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/roles/aptly/tests/tmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/roles/backup_manager/.gitignore b/roles/backup_manager/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/backup_manager/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/backup_manager/.manala/make/Makefile b/roles/backup_manager/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/backup_manager/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/backup_manager/.manala/make/Makefile.docker b/roles/backup_manager/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/backup_manager/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/backup_manager/.manala/make/Makefile.host b/roles/backup_manager/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/backup_manager/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/backup_manager/.manala/make/Makefile.manala b/roles/backup_manager/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/backup_manager/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/backup_manager/.manala/make/Makefile.travis b/roles/backup_manager/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/backup_manager/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/backup_manager/.manala/make/gmsl/__gmsl b/roles/backup_manager/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/backup_manager/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/backup_manager/.manala/make/gmsl/gmsl b/roles/backup_manager/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/backup_manager/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/backup_manager/.travis.yml b/roles/backup_manager/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/backup_manager/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/backup_manager/CHANGELOG.md b/roles/backup_manager/CHANGELOG.md deleted file mode 100644 index 6355f10ab..000000000 --- a/roles/backup_manager/CHANGELOG.md +++ /dev/null @@ -1,80 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.6] - 2020-12-16 -### Added -- Config filters - -### Changed -- Use unified exclusive template lookup -- Deprecate dbms oriented templates -- Deprecate dict's array configs - -## [2.0.5] - 2020-11-12 -### Added -- Handle list configs parameters - -## [2.0.4] - 2020-10-09 -### Added -- Lookup to handle arrays in configs - -## [2.0.3] - 2020-08-28 -### Changed -- Explicit file permissions - -## [2.0.2] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.1] - 2019-11-29 -### Changed -- Update 'lookup' to use 'query' -- Minimum required version of ansible up to 2.5.0 - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -### Added -- Handle configs states (present|absent) & raw content - -## [1.0.6] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.5] - 2019-05-21 -### Changed -- Turn off scp upload & cdrw burning methods by default -- Configs templates are now inherited from a base one - -## [1.0.4] - 2018-11-12 -### Changed -- Update to Backup Manager 0.7.14 configs templates - -## [1.0.3] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.2] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Replace deprecated uses of "include" -- Use native config template default values type when possible -- Allow S3 configuration for MySQL and PGSQL -- Pass apt module packages list directly to the `name` option - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.0] - 2017-01-09 -### Added -- Handle installation -- Handle configs diff --git a/roles/backup_manager/Makefile b/roles/backup_manager/Makefile deleted file mode 100644 index c3e59c8e3..000000000 --- a/roles/backup_manager/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.backup_manager -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/backup_manager/README.md b/roles/backup_manager/README.md index d61e7fe26..cd5263561 100644 --- a/roles/backup_manager/README.md +++ b/roles/backup_manager/README.md @@ -1,24 +1,12 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Backup Manager [![Build Status](https://travis-ci.org/manala/ansible-role-backup_manager.svg?branch=master)](https://travis-ci.org/manala/ansible-role-backup_manager) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Backup Manager This role will deal with the setup of [Backup Manager](https://github.com/sukria/Backup-Manager). -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements -This role is made to work with the backup-manager debian package, available on the __manala__ debian repository for jessie and stretch. Please use the [**manala.apt**](https://galaxy.ansible.com/manala/apt/) role to handle it properly. +This role is made to work with the backup-manager debian package, available on the __manala__ debian repository for stretch. Please use the [**manala.roles.apt**](../apt/) role to handle it properly. ```yaml manala_apt_preferences: @@ -31,33 +19,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.backup_manager -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.backup_manager -``` +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| ------------------------------------------------ | -------------------------- | ------- | -------------------------------------- | -| `manala_backup_manager_install_packages` | ~ | Array | Dependency packages to install | -| `manala_backup_manager_install_packages_default` | ['backup-manager'] | Array | Default dependency packages to install | -| `manala_backup_manager_configs_exclusive` | false | Boolean | Configs exclusivity | -| `manala_backup_manager_configs_dir` | '/etc/backup-manager.d' | String | Configs directory path | -| `manala_backup_manager_configs_defaults` | {} | String | Configs defaults | -| `manala_backup_manager_configs` | [] | Array | Collection of configs | -| `manala_backup_manager_bin` | '/usr/sbin/backup-manager' | String | Binary path | - -### Backup manager variable +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file #### Local Storage @@ -67,7 +33,7 @@ To setup where and how store backups | --------------------- | ----------------------------- | ------- | ------------------------------------ | | `BM_REPOSITORY_ROOT` | '/srv/backup' | String | Path where local backups are stored | | `BM_REPOSITORY_CHMOD` | 755 | Octal | Backup directory mode | -| `BM_ARCHIVE_TTL' | 5 | Integer | Number of backup to keep | +| `BM_ARCHIVE_TTL` | 5 | Integer | Number of backup to keep | | `BM_ARCHIVE_METHOD` | 'tarball tarball-incremental' | String | How backups are stored (you can mix) | | `BM_ARCHIVE_CHMOD` | 644 | Octal | Backup files mode | | `BM_ARCHIVE_PREFIX` | 'backup_' | String | Prefix of the backup files | @@ -166,18 +132,6 @@ manala_backup_manager_configs: template: my/backup_manager.conf.j2 config: foo: bar - # Dict's array (deprecated) - - file: foo.conf - template: configs/mysql.j2 - config: - - BM_REPOSITORY_CHMOD: 775 - - BM_ARCHIVE_CHMOD: 664 - - BM_REPOSITORY_ROOT: /srv/backup/mysql - # Flatten configs - - BM_TARBALL_DIRECTORIES: - - foo - - bar - - "{{ my_custom_configs_array }}" # Ensure config is absent - file: absent.conf state: absent # "present" by default @@ -219,8 +173,9 @@ manala_backup_manager_configs: ```yaml - hosts: servers - roles: - - role: manala.backup_manager + tasks: + - import_role: + name: manala.roles.backup_manager ``` ## CRON @@ -238,9 +193,11 @@ manala_cron_files: hour: 6 ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/backup_manager/defaults/main.yml b/roles/backup_manager/defaults/main.yml index 6c137d741..09666b1d9 100644 --- a/roles/backup_manager/defaults/main.yml +++ b/roles/backup_manager/defaults/main.yml @@ -8,9 +8,7 @@ manala_backup_manager_install_packages_default: # Configs manala_backup_manager_configs_exclusive: false manala_backup_manager_configs_dir: /etc/backup-manager.d -manala_backup_manager_configs_template: ~ # Deprecated -manala_backup_manager_configs_defaults: - template: "{{ manala_backup_manager_configs_template }}" # Ensure backward compatibility +manala_backup_manager_configs_defaults: {} manala_backup_manager_configs: [] # Bin diff --git a/roles/backup_manager/filter_plugins/.gitignore b/roles/backup_manager/filter_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/backup_manager/filter_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/backup_manager/filter_plugins/manala_backup_manager.py b/roles/backup_manager/filter_plugins/manala_backup_manager.py deleted file mode 100644 index 83d419793..000000000 --- a/roles/backup_manager/filter_plugins/manala_backup_manager.py +++ /dev/null @@ -1,70 +0,0 @@ -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -from ansible.errors import AnsibleFilterError -from ansible.module_utils.six import iteritems, string_types -from ansible.plugins.filter.core import flatten - -from numbers import Number - - -def config(parameters, exclude=[]): - if not isinstance(parameters, dict): - raise AnsibleFilterError('manala_backup_manager_config expects a dict but was given a %s' % type(parameters)) - [parameters.pop(key, None) for key in exclude] - result = '' - for key in sorted(parameters): - parameter = config_parameter(parameters, key) - if parameter: - result += '\n%s' % parameter - return result - - -def config_parameter(parameters, key, required=False, default=None, comment=False): - if not isinstance(parameters, dict): - raise AnsibleFilterError('manala_backup_manager_config_parameter parameters expects a dict but was given a %s' % type(parameters)) - if not isinstance(key, string_types): - raise AnsibleFilterError('manala_backup_manager_config_parameter key expects a string but was given a %s' % type(key)) - if required and key not in parameters: - raise AnsibleFilterError('manala_backup_manager_config_parameter requires a value for key %s' % key) - result = '' - value = parameters.get(key, default) - if value is None: - result = 'export %s="none"' % key - if value is True: - result = 'export %s="true"' % key - elif value is False: - result = 'export %s="false"' % key - elif isinstance(value, list): - value = flatten(value) - if value and all(isinstance(v, dict) for v in value): - for index, value in enumerate(value): - for k, v in iteritems(value): - result += '%s_%s[%d]="%s"\n' % (key, k, index, v) - result = result.rstrip() - else: - result = 'export %s="%s"' % (key, ' '.join(value)) - elif isinstance(value, string_types): - result = 'export %s="%s"' % (key, value) - elif isinstance(value, Number): - result = 'export %s="%s"' % (key, value) - else: - AnsibleFilterError('manala_backup_manager_config_parameter value of an unknown type %s' % type(value)) - if key not in parameters: - if comment is True: - result = '#%s' % result - elif isinstance(comment, string_types): - result = comment - return result - - -class FilterModule(object): - ''' Manala backup manager jinja2 filters ''' - - def filters(self): - filters = { - 'manala_backup_manager_config': config, - 'manala_backup_manager_config_parameter': config_parameter, - } - - return filters diff --git a/roles/backup_manager/lookup_plugins/.gitignore b/roles/backup_manager/lookup_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/backup_manager/lookup_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/backup_manager/lookup_plugins/manala_backup_manager_config.py b/roles/backup_manager/lookup_plugins/manala_backup_manager_config.py deleted file mode 100644 index 158dc8ea8..000000000 --- a/roles/backup_manager/lookup_plugins/manala_backup_manager_config.py +++ /dev/null @@ -1,39 +0,0 @@ -# Deprecated - -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.module_utils.six import string_types, iteritems -from ansible.errors import AnsibleError - - -class LookupModule(LookupBase): - - def format_row(self, key, value, type): - result = '' - if type == 'array': - if not isinstance(value, list): - raise AnsibleError('Expected a list for key "%s" in manala_backup_manager config' % key) - for index, val in enumerate(value): - if not isinstance(val, dict): - raise AnsibleError('Expected a dict for key "%s" values in manala_backup_manager config' % key) - for k, v in iteritems(val): - result += "%s_%s[%d]=\"%s\"\n" % (key, k, index, v) - return result - - def run(self, terms, variables=None, **kwargs): - - wantrow = kwargs.pop('wantrow', None) - wantrowtype = kwargs.pop('wantrowtype', None) - wantrowdefault = kwargs.pop('wantrowdefault', None) - - config = self._flatten(terms) - - for row in config: - for key, value in iteritems(row): - if key == wantrow: - return self.format_row(key, value, wantrowtype) - - if wantrowdefault: - return wantrowdefault diff --git a/roles/backup_manager/lookup_plugins/manala_templates_exclusive.py b/roles/backup_manager/lookup_plugins/manala_templates_exclusive.py deleted file mode 100644 index ff57727f0..000000000 --- a/roles/backup_manager/lookup_plugins/manala_templates_exclusive.py +++ /dev/null @@ -1,103 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.errors import AnsibleError -from ansible.module_utils._text import to_text - -import os - - -class LookupModule(LookupBase): - - def _recursive_flatten(self, terms): - if not isinstance(terms, list): - raise AnsibleError('Expect a list but was a %s' % type(terms)) - ret = [] - for term in terms: - if isinstance(term, (list, tuple)): - ret.extend( - self._recursive_flatten(term) - ) - else: - ret.append(term) - return ret - - def run(self, terms, variables=None, **kwargs): - - results = [] - - wantstate = kwargs.pop('wantstate', None) - - if wantstate and wantstate not in ['present', 'absent']: - raise AnsibleError('Expect a wanstate of "present" or "absent" but was "%s"' % to_text(wantstate)) - - templates = self._recursive_flatten(terms[0]) - exclusives = self._flatten(terms[1]) - dir = terms[2] - template = terms[3] - - itemDefault = { - 'state': 'present', - 'template': template - } - - # Mark exclusive templates as absent - for template in exclusives: - item = itemDefault.copy() - item.update({ - 'file': template['path'], - 'state': 'absent' - }) - results.append(item) - - for template in templates: - - items = [] - - # Must be a dict - if not isinstance(template, dict): - raise AnsibleError('Expect a dict but was a %s' % type(template)) - - # Check file key - if 'file' not in template: - # File name based on template - if 'template' in template: - template['file'] = os.path.splitext( - os.path.basename(template['template']) - )[0] - else: - raise AnsibleError('Expect a "file" key') - - item = itemDefault.copy() - item.update(template) - - if item['state'] not in ['present', 'absent', 'ignore']: - raise AnsibleError('Expect a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) - - if item['state'] == 'ignore': - continue - - item.update({ - 'file': os.path.join(dir, item['file']) - }) - - items.append(item) - - # Merge by file key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['file'] == item['file']: - results[i] = item - itemFound = True - break - - if not itemFound: - results.append(item) - - # Filter by state - if wantstate: - results = [result for result in results if result.get('state') == wantstate] - - return results diff --git a/roles/backup_manager/meta/main.yml b/roles/backup_manager/meta/main.yml index 1c16bf9f1..70fe5e0bf 100644 --- a/roles/backup_manager/meta/main.yml +++ b/roles/backup_manager/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: backup_manager - author: Manala - company: Manala - description: Handle backup manager - license: MIT - min_ansible_version: 2.5.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: backup_manager + author: Manala + company: Manala + description: Handle backup manager + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - backup diff --git a/roles/backup_manager/tasks/configs.yml b/roles/backup_manager/tasks/configs.yml index 0ed14f46e..0bec5a16f 100644 --- a/roles/backup_manager/tasks/configs.yml +++ b/roles/backup_manager/tasks/configs.yml @@ -12,6 +12,7 @@ - name: configs > Exclusive find: path: "{{ manala_backup_manager_configs_dir }}" + file_type: file patterns: "*" changed_when: false register: __manala_backup_manager_configs_exclusive_find @@ -25,25 +26,23 @@ group: root mode: "0600" loop: "{{ query( - 'manala_templates_exclusive', - manala_backup_manager_configs, - __manala_backup_manager_configs_exclusive_find.files|default([]), - manala_backup_manager_configs_dir, - manala_backup_manager_configs_defaults.template|default('configs/_default.j2', true), - wantstate='present' - ) - }}" + 'manala.roles.templates_exclusive', + manala_backup_manager_configs, + __manala_backup_manager_configs_exclusive_find.files|default([]), + manala_backup_manager_configs_dir, + manala_backup_manager_configs_defaults.template|default('configs/_default.j2', true), + wantstate='present' + ) }}" - name: configs > Files absent file: path: "{{ item.file }}" state: absent loop: "{{ query( - 'manala_templates_exclusive', - manala_backup_manager_configs, - __manala_backup_manager_configs_exclusive_find.files|default([]), - manala_backup_manager_configs_dir, - manala_backup_manager_configs_defaults.template|default('configs/_default.j2', true), - wantstate='absent' - ) - }}" + 'manala.roles.templates_exclusive', + manala_backup_manager_configs, + __manala_backup_manager_configs_exclusive_find.files|default([]), + manala_backup_manager_configs_dir, + manala_backup_manager_configs_defaults.template|default('configs/_default.j2', true), + wantstate='absent' + ) }}" diff --git a/roles/backup_manager/tasks/install.yml b/roles/backup_manager/tasks/install.yml index ee753f647..fc8664383 100644 --- a/roles/backup_manager/tasks/install.yml +++ b/roles/backup_manager/tasks/install.yml @@ -2,7 +2,9 @@ - name: install > Packages apt: - name: "{{ manala_backup_manager_install_packages|default(manala_backup_manager_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_backup_manager_install_packages|default(manala_backup_manager_install_packages_default, True) }}" diff --git a/roles/backup_manager/templates/configs/_base.j2 b/roles/backup_manager/templates/configs/_base.j2 deleted file mode 100644 index 7717fd542..000000000 --- a/roles/backup_manager/templates/configs/_base.j2 +++ /dev/null @@ -1,573 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = item.config|default([]) -%} - -# Backup Manager Configuration File -# -# * This configuration file is divided into sections. -# The 'global' section is mandatory, every keys defined in -# this section are inherited in the other sections. -# * There is one section per "backup method", you have to -# fill the section of the chosen method. -# -############################################################## - -############################################################## -# Repository - everything about where archives are -############################################################# - -# Where to store the archives -{{ macros.config_row(config, 'BM_REPOSITORY_ROOT', '/var/archives') }} - -# Where to place temporary files -{{ macros.config_row(config, 'BM_TEMP_DIR', '/tmp') }} - -# For security reasons, the archive repository and the generated -# archives will be readable/writable by a given user/group. -# This is recommended to set this to true. -{{ macros.config_row(config, 'BM_REPOSITORY_SECURE', true) }} - -# The repository will be readable/writable only by a specific -# user:group pair if BM_REPOSITORY_SECURE is set to true. -{{ macros.config_row(config, 'BM_REPOSITORY_USER', 'root') }} -{{ macros.config_row(config, 'BM_REPOSITORY_GROUP', 'root') }} -# You can also choose the permission to set the repository, default -# is 770, pay attention to what you do there! -{{ macros.config_row(config, 'BM_REPOSITORY_CHMOD', 770) }} - -############################################################## -# Archives - let's focus on the precious tarballs... -############################################################## - -# Each archive generated will be chmoded for security reasons -# (BM_REPOSITORY_SECURE should be enabled for this). -{{ macros.config_row(config, 'BM_ARCHIVE_CHMOD', 660) }} - -# Number of days we have to keep an archive (Time To Live) -{{ macros.config_row(config, 'BM_ARCHIVE_TTL', 5) }} - -# Do you want to purge only the top-level directory or all -# directories under BM_REPOSITORY_ROOT? -{{ macros.config_row(config, 'BM_REPOSITORY_RECURSIVEPURGE', false) }} - -# Do you want to replace duplicates by symlinks? -# (archive-DAY is a duplicate of archive-(DAY - 1) if they -# are both the same according to MD5 hashes). -{{ macros.config_row(config, 'BM_ARCHIVE_PURGEDUPS', true) }} - -# Prefix of every archive on that box (default is HOSTNAME) -{{ macros.config_row(config, 'BM_ARCHIVE_PREFIX', '$HOSTNAME') }} - -# Should we purge only archives built with $BM_ARCHIVE_PREFIX -{{ macros.config_row(config, 'BM_ARCHIVE_STRICTPURGE', true) }} - -# You may want to nice the commands run for archive-creation -# (Recommanded for desktop users.) -# Choose a nice level from -20 (most favorable scheduling) to 19 (least favorable). -{{ macros.config_row(config, 'BM_ARCHIVE_NICE_LEVEL', 10) }} - -# The backup method to use. -# Available methods are: -# - tarball -# - tarball-incremental -# - mysql -# - pgsql -# - svn -# - pipe -# - none -# If you don't want to use any backup method (you don't want to -# build archives) then choose "none" -{{ macros.config_row(config, 'BM_ARCHIVE_METHOD', config_default['BM_ARCHIVE_METHOD']|default('tarball')) }} - -############################################################## -# Encryption - because you cannot trust the place your -# archives are -############################################################## - -# If you want to encrypt your archives locally, Backup Manager -# can use GPG while building the archive (so the archive is never -# written to the disk without being encrypted. - -# Note: this feature is only possible with the following archive types: -# tar, tar.gz, tar.bz2 - -# Uncomment the following line if you want to enable encryption -# available method: gpg -{{ macros.config_row(config, 'BM_ENCRYPTION_METHOD', false) }} - -# The encryption will be made using a GPG ID -# Examples: -# export BM_ENCRYPTION_RECIPIENT="" -# export BM_ENCRYPTION_RECIPIENT="" -{{ macros.config_row(config, 'BM_ENCRYPTION_RECIPIENT', '') }} - - -############################################################## -# Section "TARBALL" -# - Backup method: tarball -############################################################# - -# Archive filename format -# long : host-full-path-to-folder.tar.gz -# short : parentfolder.tar.gz -{{ macros.config_row(config, 'BM_TARBALL_NAMEFORMAT', 'long') }} - -# Type of archives -# Available types are: -# tar, tar.gz, tar.bz2, tar.xz, tar.lzma, dar, zip. -# Make sure to satisfy the appropriate dependencies -# (bzip2, dar, xz, lzma, ...). -{{ macros.config_row(config, 'BM_TARBALL_FILETYPE', 'tar.gz') }} - -# You can choose to build archives remotely over SSH. -# You will then need to fill the BM_UPLOAD_SSH variables -# (BM_UPLOAD_SSH_HOSTS, BM_UPLOAD_SSH_USER, BM_UPLOAD_SSH_KEY). -# If this boolean is set to true, archive will be saved locally (in -# BM_REPOSITORY_ROOT but will be built by the remote host). -# Thus, BM_TARBALL_DIRECTORIES will be used to backup remote directories. -# Those archive will be prefixed with the remote host name. -{{ macros.config_row(config, 'BM_TARBALL_OVER_SSH', false) }} - -# Do you want to dereference the files pointed by symlinks ? -# enter true or false (true can lead to huge archives, be careful). -{{ macros.config_row(config, 'BM_TARBALL_DUMPSYMLINKS', false) }} - -# Targets to backup - -# You can use two different variables for defining the targets of -# your backups, either a simple space-separated list (BM_TARBALL_DIRECTORIES) -# or an array (BM_TARBALL_TARGETS[]). -# Use the first one for simple path that doesn't contain spaces in their name. -# Use the former if you want to specify paths to backups with spaces. - -# It's recommanded to use BM_TARBALL_TARGETS[] though. -# Warning! You *must not* use both variables at the same time. -# NOTE: The Debian package will only update BM_TARBALL_DIRECTORIES - -# Paths without spaces in their name: -{{ macros.config_row(config, 'BM_TARBALL_DIRECTORIES', '/etc /home') }} - -# If one or more of the targets contain a space, use the array: -# declare -a BM_TARBALL_TARGETS -# BM_TARBALL_TARGETS[0]="/etc" -# BM_TARBALL_TARGETS[1]="/boot" -# export BM_TARBALL_TARGETS - -# Files to exclude when generating tarballs, you can put absolute -# or relative paths, Bash wildcards are possible. -{{ macros.config_row(config, 'BM_TARBALL_BLACKLIST', '/var/archives') }} - -# With the "dar" filetype, you can choose a maximum slice limit. -{{ macros.config_row(config, 'BM_TARBALL_SLICESIZE', '1000M') }} - -# Extra options to append to the tarball generation -# (take care to what you do; this will be silently added to the -# command line.) -{{ macros.config_row(config, 'BM_TARBALL_EXTRA_OPTIONS', '') }} - -############################################################## -# The tarball-incremental method uses the same keys as the -# tarball method, plus two others. -############################################################# - -# Which frequency to use for the master tarball? -# possible values: weekly, monthly -{{ macros.config_row(config, 'BM_TARBALLINC_MASTERDATETYPE', 'weekly') }} - -# Number of the day, in the BM_TARBALLINC_MASTERDATETYPE frequency -# when master tarballs should be made -{{ macros.config_row(config, 'BM_TARBALLINC_MASTERDATEVALUE', 1) }} - -# Examples: you want to make master tarballs every friday: -# BM_TARBALLINC_MASTERDATETYPE="weekly" -# BM_TARBALLINC_MASTERDATEVALUE="5" -# -# Or every first day of the month: -# BM_TARBALLINC_MASTERDATETYPE="monthly" -# BM_TARBALLINC_MASTERDATEVALUE="1" - -############################################################## -# Backup method: MYSQL -############################################################# - -# This method is dedicated to MySQL databases. -# You should not use the tarball method for backing up database -# directories or you may have corrupted archives. -# Enter here the list of databases to backup. -# Wildcard: __ALL__ (will dump all the databases in one archive) -{{ macros.config_row(config, 'BM_MYSQL_DATABASES', '__ALL__') }} - -# The best way to produce MySQL dump is done by using the "--opt" switch -# of mysqldump. This make the dump directly usable with mysql (add the drop table -# statements), lock the tables during the dump and other things. -# This is recommended for full-clean-safe backups, but needs a -# privileged user (for the lock permissions). -{{ macros.config_row(config, 'BM_MYSQL_SAFEDUMPS', true) }} - -# The user who is allowed to read every databases filled in BM_MYSQL_DATABASES -{{ macros.config_row(config, 'BM_MYSQL_ADMINLOGIN', 'root') }} - -# its password -{{ macros.config_row(config, 'BM_MYSQL_ADMINPASS', '') }} - -# the host where the database is -{{ macros.config_row(config, 'BM_MYSQL_HOST', 'localhost') }} - -# the port where MySQL listen to on the host -{{ macros.config_row(config, 'BM_MYSQL_PORT', 3306) }} - -# which compression format to use? (gzip or bzip2) -{{ macros.config_row(config, 'BM_MYSQL_FILETYPE', 'bzip2') }} - -# Extra options to append to mysqldump -# (take care to what you do; this will be silently added to the -# command line.) -{{ macros.config_row(config, 'BM_MYSQL_EXTRA_OPTIONS', '') }} - -# Make separate backups of each database? -{{ macros.config_row(config, 'BM_MYSQL_SEPARATELY', true) }} - -# Specify DBs to exclude here (separated by space) -{{ macros.config_row(config, 'BM_MYSQL_DBEXCLUDE', '') }} - -############################################################## -# Backup method: PostgreSQL -############################################################# - -# This method is dedicated to PostgreSQL databases. -# You should not use the tarball method for backing up database -# directories or you may have corrupted archives. -# Enter here the list of databases to backup. -# Wildcard: __ALL__ (will dump all the databases in one archive) -{{ macros.config_row(config, 'BM_PGSQL_DATABASES', '__ALL__') }} - -# The user who is allowed to read every databases filled in BM_PGSQL_DATABASES -{{ macros.config_row(config, 'BM_PGSQL_ADMINLOGIN', 'root') }} - -# its password -{{ macros.config_row(config, 'BM_PGSQL_ADMINPASS', '') }} - -# the host where the database is -{{ macros.config_row(config, 'BM_PGSQL_HOST', 'localhost') }} - -# the port where PostgreSQL listen to on the host -{{ macros.config_row(config, 'BM_PGSQL_PORT', 5432) }} - -# which compression format to use? (gzip or bzip2) -{{ macros.config_row(config, 'BM_PGSQL_FILETYPE', 'bzip2') }} - -# Extra options to append to pg_dump -# (take care to what you do; this will be silently added to the -# command line.) -{{ macros.config_row(config, 'BM_PGSQL_EXTRA_OPTIONS', '') }} - -############################################################## -# Backup method: svn -############################################################# - -# Absolute paths to the svn repositories to archive -{{ macros.config_row(config, 'BM_SVN_REPOSITORIES', '') }} - -# You can compress the resulting XML files -# Supported compressor are: bzip2 and gzip -{{ macros.config_row(config, 'BM_SVN_COMPRESSWITH', 'bzip2') }} - -############################################################## -# Backup method: pipe -############################################################# - -# The "pipe" method is a generic way of making archive. -# Its concept is simple, for every kind of archive you want -# to make, you give: a command which will send output on stdout, -# a name, a file type and optionnaly, a compressor. - -# Be careful, this feature uses arrays! -declare -a BM_PIPE_COMMAND -declare -a BM_PIPE_NAME -declare -a BM_PIPE_FILETYPE -declare -a BM_PIPE_COMPRESS - -{{ query('manala_backup_manager_config', config, wantrow='BM_PIPE', wantrowtype='array', wantrowdefault='# You can virtually implement whatever backup scenario you like -# with this method. -# -# The resulting archives will be named like this: -# $BM_ARCHIVE_PREFIX-$BM_PIPE_NAME.$DATE.$BM_PIPE_FILETYPE -# If you specified a BM_PIPE_COMPRESS option, the resulting filename -# will change as expected (eg, .gz if "gzip"). -# -# Here are a couple of examples for using this method: - -# Archive a remote MySQL database through SSH: -# BM_PIPE_COMMAND[0]="ssh host -c \\"mysqldump -ufoo -pbar base\\"" -# BM_PIPE_NAME[0]="base" -# BM_PIPE_FILETYPE[0]="sql" -# BM_PIPE_COMPRESS[0]="gzip" -# This will make somthing like: localhost-base.20050421.sql.gz - -# Archive a specific directory, on a remote server through SSH: -# BM_PIPE_COMMAND[0]="ssh host -c \\"tar -c -z /home/user\\"" -# BM_PIPE_NAME[0]="host.home.user" -# BM_PIPE_FILETYPE[0]="tar.gz" -# BM_PIPE_COMPRESS[0]="" -# This will make somthing like: localhost-host.home.user.20050421.tar.gz') }} - -export BM_PIPE_COMMAND -export BM_PIPE_NAME -export BM_PIPE_FILETYPE -export BM_PIPE_COMPRESS - -############################################################## -# Section "UPLOAD" -# You can upload archives to remote hosts with different -# methods. -############################################################# - -# Which method to use for uploading archives, you can put -# multiple methods here. -# Available methods: -# - scp -# - ssh-gpg -# - ftp -# - rsync -# - s3 -# - none - -# If you don't want to use any upload method (you don't want to -# upload files to remote hosts) then choose "none" -{{ macros.config_row(config, 'BM_UPLOAD_METHOD', none) }} - -# where to upload (global to all methods. Not required to be set for S3) -{{ macros.config_row(config, 'BM_UPLOAD_HOSTS', '') }} - -# Where to put archives on the remote hosts (global) -{{ macros.config_row(config, 'BM_UPLOAD_DESTINATION', '/var/archives/uploads') }} - -# Uncomment the 'export ...' line below to activate the uploaded archives -# database. -# Using the database will avoid extraneous uploads to remote hosts in the -# case of running more than one backup-manager jobs per day (such as when -# you are using different configuration files for different parts of your -# filesystem). -# Note that when you upload to multiple hosts, a single succesfull upload -# will mark the archive as uploaded. Thus upload errors to specific hosts -# will have to be resolved manually. -# You can specify any filename, but it is recommended to keep the database -# inside the archive repository. The variable's value has been preset to -# that. -#export BM_UPLOADED_ARCHIVES=${BM_REPOSITORY_ROOT}/${BM_ARCHIVE_PREFIX}-uploaded.list - -############################################################## -# The SSH method -############################################################# - -# the user to use for the SSH connections/transfers -{{ macros.config_row(config, 'BM_UPLOAD_SSH_USER', 'bmngr') }} - -# The private key to use for opening the connection -{{ macros.config_row(config, 'BM_UPLOAD_SSH_KEY', '') }} - -# specific ssh hosts -{{ macros.config_row(config, 'BM_UPLOAD_SSH_HOSTS', '') }} - -# port to use for SSH connections (leave blank for default one) -{{ macros.config_row(config, 'BM_UPLOAD_SSH_PORT', '') }} - -# destination for ssh uploads (overrides BM_UPLOAD_DESTINATION) -{{ macros.config_row(config, 'BM_UPLOAD_SSH_DESTINATION', '') }} - -# purge archives on remote hosts before uploading? -{{ macros.config_row(config, 'BM_UPLOAD_SSH_PURGE', true) }} - -# If you set BM_UPLOAD_SSH_PURGE, you can specify a time to live -# for archives uploaded with SSH. -# This can let you use different ttl's locally and remotely -# By default, BM_ARCHIVE_TTL will be used. -{{ macros.config_row(config, 'BM_UPLOAD_SSH_TTL', '') }} - -############################################################## -# The SSH-GPG method -# The ssh-gpg method uses the same configuration keys as the -# ssh method, plus one other -############################################################# - -# The gpg public key used for encryption, this can be a short -# or long key id, or a descriptive name. See gpg man page for -# all possibilities how to specify a key. -{{ macros.config_row(config, 'BM_UPLOAD_SSHGPG_RECIPIENT', '') }} - -############################################################## -# The FTP method -############################################################# - -# Use FTP secured transfers (FTP over TLS) -# User, password and data will be uploaded encrypted with SSL. -# Passive mode will be automaticaly activated -{{ macros.config_row(config, 'BM_UPLOAD_FTP_SECURE', false) }} - -# Do you want to use FTP passive mode? -# This is mandatory for NATed/firewalled environments -{{ macros.config_row(config, 'BM_UPLOAD_FTP_PASSIVE', true) }} - -# Timeout (in seconds) for FTP transfer -# This setting only has effect when using FTP transfer with -# secure mode disabled (BM_UPLOAD_FTP_SECURE to "false") -{{ macros.config_row(config, 'BM_UPLOAD_FTP_TIMEOUT', 120) }} - -# Test the FTP connection before starting archives upload. -# This will enable BM to try sending a 2MB test file before -# sending any archive -{{ macros.config_row(config, 'BM_UPLOAD_FTP_TEST', false) }} - -# the user to use for the FTP connections/transfers -{{ macros.config_row(config, 'BM_UPLOAD_FTP_USER', '') }} - -# the FTP user's password -{{ macros.config_row(config, 'BM_UPLOAD_FTP_PASSWORD', '') }} - -# FTP specific remote hosts -{{ macros.config_row(config, 'BM_UPLOAD_FTP_HOSTS', '') }} - -# purge archives on remote hosts before uploading? -{{ macros.config_row(config, 'BM_UPLOAD_FTP_PURGE', true) }} - -# You can specify a time to live for archives uploaded with FTP -# This can let you use different ttl's locally and remotely -# By default, BM_ARCHIVE_TTL will be used. -{{ macros.config_row(config, 'BM_UPLOAD_FTP_TTL', '') }} - -# destination for FTP uploads (overrides BM_UPLOAD_DESTINATION) -{{ macros.config_row(config, 'BM_UPLOAD_FTP_DESTINATION', '') }} - - -############################################################## -# The S3 method -############################################################# - -# The Amazon S3 method requires that you secure an S3 -# account. See http://aws.amazon.com - -# The bucket to upload to. This bucket must be dedicated to backup-manager -{{ macros.config_row(config, 'BM_UPLOAD_S3_DESTINATION', '') }} - -# the S3 access key provided to you -{{ macros.config_row(config, 'BM_UPLOAD_S3_ACCESS_KEY', '') }} - -# the S3 secret key provided to you -{{ macros.config_row(config, 'BM_UPLOAD_S3_SECRET_KEY', '') }} - -# purge archives on remote hosts before uploading? -{{ macros.config_row(config, 'BM_UPLOAD_S3_PURGE', false) }} - -# You can specify a time to live for archives uploaded to S3 -# This can let you use different ttl's locally and remotely -# By default, BM_ARCHIVE_TTL will be used. -{{ macros.config_row(config, 'BM_UPLOAD_S3_TTL', '') }} - -############################################################## -# The RSYNC method -############################################################# - -# Which directories should be backuped with rsync -{{ macros.config_row(config, 'BM_UPLOAD_RSYNC_DIRECTORIES', '') }} - -# Destination for rsync uploads (overrides BM_UPLOAD_DESTINATION) -{{ macros.config_row(config, 'BM_UPLOAD_RSYNC_DESTINATION', '') }} - -# The list of remote hosts, if you want to enable the upload -# system, just put some remote hosts here (fqdn or IPs) -# Leave it empty if you want to use the hosts that are defined in -# BM_UPLOAD_HOSTS -{{ macros.config_row(config, 'BM_UPLOAD_RSYNC_HOSTS', '') }} - -# Do you want to dereference the files pointed by symlinks? -# enter true or false (true can lead to huge archives, be careful). -{{ macros.config_row(config, 'BM_UPLOAD_RSYNC_DUMPSYMLINKS', false) }} - -# Files/folders to exclude when rsyncing. Warning: rsync will interpret -# it as a mask, so will exclude any file/folder corresponding to it -{{ macros.config_row(config, 'BM_UPLOAD_RSYNC_BLACKLIST', '') }} - -# Extra options to append to rsync -# (take care to what you do; this will be silently added to the -# command line.) -{{ macros.config_row(config, 'BM_UPLOAD_RSYNC_EXTRA_OPTIONS', '') }} - -# Do you want to limit the maximum available bandwidth rsync -# can use ? -# By default, no bandwidth limit is applied. -# Example: 32M, 1024K, ... -{{ macros.config_row(config, 'BM_UPLOAD_RSYNC_BANDWIDTH_LIMIT', '') }} - -############################################################## -# Section "BURNING" -# - Automatic CDR/CDRW/DVDR burning -############################################################# - -# the method of burning archives from the list : -# - DVD : burn archives on a DVD medium -# (that doesn't need formatting, like DVD+RW). -# -# - DVD-RW : blank the DVD medium and burn archives -# (recommanded for DVD-RW media). -# -# - CDRW : blank the CDRW and burn the whole -# ARCHIVES_REPOSITORY or only -# the generated archives. -# -# - CDR : burn the whole ARCHIVES_REPOSITORY or -# only the generated archives. -# - none : disable the burning system -# -# Note that if backup-manager is run from interactive prompt you -# will be asked to insert disc(s) when needed - -{{ macros.config_row(config, 'BM_BURNING_METHOD', none) }} - -# When the CD is burnt, it is possible to check every file's -# MD5 checksum to see if the CD is not corrupted. -{{ macros.config_row(config, 'BM_BURNING_CHKMD5', false) }} - -# The device to use for mounting the cdrom -{{ macros.config_row(config, 'BM_BURNING_DEVICE', '/dev/cdrom') }} - -# You can force cdrecord to use a specific device -# Fill in the full path to the device to use or even -# e.g. BM_BURNING_DEVFORCED="/dev/cdrom" -# If none specified, the default cdrecord device will be used. -{{ macros.config_row(config, 'BM_BURNING_DEVFORCED', '') }} - -# By default backup-manager will make Joliet media (using the mkisofs switches -# : "-R -J"). You can change these if you want to use non-Joliet disc images. -# Change this only if you know what you're doing. Refer to mkisofs(8) for -# details. -{{ macros.config_row(config, 'BM_BURNING_ISO_FLAGS', '-R -J') }} - -# enter here the max size of your media -# (usal sizes are 4200 for DVD media and 700 or 800 for CDR media) -{{ macros.config_row(config, 'BM_BURNING_MAXSIZE', 650) }} - - -############################################################## -# Advanced settings, use this with care. -############################################################# - -# Every output made can be sent to syslog -# set this to "true" or "false" -{{ macros.config_row(config, 'BM_LOGGER', true) }} - -# Which level of messages do you want to log to syslog? -# possible values are : debug,info,warning,error -{{ macros.config_row(config, 'BM_LOGGER_LEVEL', 'warning') }} - -# You can choose which facility to use -{{ macros.config_row(config, 'BM_LOGGER_FACILITY', 'user') }} - -# Enter here some shell script. -# It will be executed before the first action of backup-manager. -{{ macros.config_row(config, 'BM_PRE_BACKUP_COMMAND', '') }} - -# Enter here some shell script. -# It will be executed after the last action of backup-manager. -{{ macros.config_row(config, 'BM_POST_BACKUP_COMMAND', '') }} diff --git a/roles/backup_manager/templates/configs/_default.j2 b/roles/backup_manager/templates/configs/_default.j2 index f471d8531..4e9c95711 100644 --- a/roles/backup_manager/templates/configs/_default.j2 +++ b/roles/backup_manager/templates/configs/_default.j2 @@ -2,14 +2,7 @@ {%- if config is mapping -%} -{{ config | manala_backup_manager_config }} - -{%- elif config is iterable and config is not string -%} - -{#- Deprecated -#} -{%- set config_default = {} -%} - -{% include '_base.j2' %} +{{ config | manala.roles.backup_manager_config }} {%- else -%} diff --git a/roles/backup_manager/templates/configs/_macros.j2 b/roles/backup_manager/templates/configs/_macros.j2 deleted file mode 100644 index d1ac9d55f..000000000 --- a/roles/backup_manager/templates/configs/_macros.j2 +++ /dev/null @@ -1,67 +0,0 @@ -{#- Deprecated -#} - -{%- macro config(parameters, exclusions = []) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value) }}{{ '\n' }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value) -%} - export {{ _config_parameter_key(key) }}="{{ _config_parameter_value(value) }}" -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - {{ key }} -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {%- if value is sameas none -%} - none - {%- elif value is sameas true -%} - true - {%- elif value is sameas false -%} - false - {%- elif value is string -%} - {{ value }} - {%- elif value is number -%} - {{ value }} - {%- elif value is sequence -%} - {{ value|flatten|join(' ') }} - {%- else -%} - {{ value }} - {%- endif -%} -{%- endmacro -%} diff --git a/roles/backup_manager/templates/configs/debian/backup-manager.conf.j2 b/roles/backup_manager/templates/configs/debian/backup-manager.conf.j2 index 5c44ace03..47a9b10b4 100644 --- a/roles/backup_manager/templates/configs/debian/backup-manager.conf.j2 +++ b/roles/backup_manager/templates/configs/debian/backup-manager.conf.j2 @@ -21,23 +21,23 @@ ############################################################# # Where to store the archives -{{ config | manala_backup_manager_config_parameter('BM_REPOSITORY_ROOT', default='/var/archives') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_REPOSITORY_ROOT', default='/var/archives') }} # Where to place temporary files -{{ config | manala_backup_manager_config_parameter('BM_TEMP_DIR', default='/tmp') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_TEMP_DIR', default='/tmp') }} # For security reasons, the archive repository and the generated # archives will be readable/writable by a given user/group. # This is recommended to set this to true. -{{ config | manala_backup_manager_config_parameter('BM_REPOSITORY_SECURE', default=true) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_REPOSITORY_SECURE', default=true) }} # The repository will be readable/writable only by a specific # user:group pair if BM_REPOSITORY_SECURE is set to true. -{{ config | manala_backup_manager_config_parameter('BM_REPOSITORY_USER', default='root') }} -{{ config | manala_backup_manager_config_parameter('BM_REPOSITORY_GROUP', default='root') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_REPOSITORY_USER', default='root') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_REPOSITORY_GROUP', default='root') }} # You can also choose the permission to set the repository, default # is 770, pay attention to what you do there! -{{ config | manala_backup_manager_config_parameter('BM_REPOSITORY_CHMOD', default=770) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_REPOSITORY_CHMOD', default=770) }} ############################################################## # Archives - let's focus on the precious tarballs... @@ -45,30 +45,30 @@ # Each archive generated will be chmoded for security reasons # (BM_REPOSITORY_SECURE should be enabled for this). -{{ config | manala_backup_manager_config_parameter('BM_ARCHIVE_CHMOD', default=660) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_ARCHIVE_CHMOD', default=660) }} # Number of days we have to keep an archive (Time To Live) -{{ config | manala_backup_manager_config_parameter('BM_ARCHIVE_TTL', default=5) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_ARCHIVE_TTL', default=5) }} # Do you want to purge only the top-level directory or all # directories under BM_REPOSITORY_ROOT? -{{ config | manala_backup_manager_config_parameter('BM_REPOSITORY_RECURSIVEPURGE', default=False) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_REPOSITORY_RECURSIVEPURGE', default=False) }} # Do you want to replace duplicates by symlinks? # (archive-DAY is a duplicate of archive-(DAY - 1) if they # are both the same according to MD5 hashes). -{{ config | manala_backup_manager_config_parameter('BM_ARCHIVE_PURGEDUPS', default=True) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_ARCHIVE_PURGEDUPS', default=True) }} # Prefix of every archive on that box (default is HOSTNAME) -{{ config | manala_backup_manager_config_parameter('BM_ARCHIVE_PREFIX', default='$HOSTNAME') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_ARCHIVE_PREFIX', default='$HOSTNAME') }} # Should we purge only archives built with $BM_ARCHIVE_PREFIX -{{ config | manala_backup_manager_config_parameter('BM_ARCHIVE_STRICTPURGE', default=True) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_ARCHIVE_STRICTPURGE', default=True) }} # You may want to nice the commands run for archive-creation # (Recommanded for desktop users.) # Choose a nice level from -20 (most favorable scheduling) to 19 (least favorable). -{{ config | manala_backup_manager_config_parameter('BM_ARCHIVE_NICE_LEVEL', default=10) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_ARCHIVE_NICE_LEVEL', default=10) }} # The backup method to use. # Available methods are: @@ -81,7 +81,7 @@ # - none # If you don't want to use any backup method (you don't want to # build archives) then choose "none" -{{ config | manala_backup_manager_config_parameter('BM_ARCHIVE_METHOD', default='tarball') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_ARCHIVE_METHOD', default='tarball') }} ############################################################## # Encryption - because you cannot trust the place your @@ -97,13 +97,13 @@ # Uncomment the following line if you want to enable encryption # available method: gpg -{{ config | manala_backup_manager_config_parameter('BM_ENCRYPTION_METHOD', default=False) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_ENCRYPTION_METHOD', default=False) }} # The encryption will be made using a GPG ID # Examples: # export BM_ENCRYPTION_RECIPIENT="" # export BM_ENCRYPTION_RECIPIENT="" -{{ config | manala_backup_manager_config_parameter('BM_ENCRYPTION_RECIPIENT', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_ENCRYPTION_RECIPIENT', default='') }} ############################################################## @@ -114,14 +114,14 @@ # Archive filename format # long : host-full-path-to-folder.tar.gz # short : parentfolder.tar.gz -{{ config | manala_backup_manager_config_parameter('BM_TARBALL_NAMEFORMAT', default='long') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_TARBALL_NAMEFORMAT', default='long') }} # Type of archives # Available types are: # tar, tar.gz, tar.bz2, tar.xz, tar.lzma, dar, zip. # Make sure to satisfy the appropriate dependencies # (bzip2, dar, xz, lzma, ...). -{{ config | manala_backup_manager_config_parameter('BM_TARBALL_FILETYPE', default='tar.gz') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_TARBALL_FILETYPE', default='tar.gz') }} # You can choose to build archives remotely over SSH. # You will then need to fill the BM_UPLOAD_SSH variables @@ -130,11 +130,11 @@ # BM_REPOSITORY_ROOT but will be built by the remote host). # Thus, BM_TARBALL_DIRECTORIES will be used to backup remote directories. # Those archive will be prefixed with the remote host name. -{{ config | manala_backup_manager_config_parameter('BM_TARBALL_OVER_SSH', default=False) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_TARBALL_OVER_SSH', default=False) }} # Do you want to dereference the files pointed by symlinks ? # enter true or false (true can lead to huge archives, be careful). -{{ config | manala_backup_manager_config_parameter('BM_TARBALL_DUMPSYMLINKS', default=False) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_TARBALL_DUMPSYMLINKS', default=False) }} # Targets to backup @@ -149,7 +149,7 @@ # NOTE: The Debian package will only update BM_TARBALL_DIRECTORIES # Paths without spaces in their name: -{{ config | manala_backup_manager_config_parameter('BM_TARBALL_DIRECTORIES', default=['/etc', '/home']) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_TARBALL_DIRECTORIES', default=['/etc', '/home']) }} # If one or more of the targets contain a space, use the array: # declare -a BM_TARBALL_TARGETS @@ -159,15 +159,15 @@ # Files to exclude when generating tarballs, you can put absolute # or relative paths, Bash wildcards are possible. -{{ config | manala_backup_manager_config_parameter('BM_TARBALL_BLACKLIST', default=['/var/archives']) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_TARBALL_BLACKLIST', default=['/var/archives']) }} # With the "dar" filetype, you can choose a maximum slice limit. -{{ config | manala_backup_manager_config_parameter('BM_TARBALL_SLICESIZE', default='1000M') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_TARBALL_SLICESIZE', default='1000M') }} # Extra options to append to the tarball generation # (take care to what you do; this will be silently added to the # command line.) -{{ config | manala_backup_manager_config_parameter('BM_TARBALL_EXTRA_OPTIONS', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_TARBALL_EXTRA_OPTIONS', default='') }} ############################################################## # The tarball-incremental method uses the same keys as the @@ -176,11 +176,11 @@ # Which frequency to use for the master tarball? # possible values: weekly, monthly -{{ config | manala_backup_manager_config_parameter('BM_TARBALLINC_MASTERDATETYPE', default='weekly') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_TARBALLINC_MASTERDATETYPE', default='weekly') }} # Number of the day, in the BM_TARBALLINC_MASTERDATETYPE frequency # when master tarballs should be made -{{ config | manala_backup_manager_config_parameter('BM_TARBALLINC_MASTERDATEVALUE', default=1) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_TARBALLINC_MASTERDATEVALUE', default=1) }} # Examples: you want to make master tarballs every friday: # BM_TARBALLINC_MASTERDATETYPE="weekly" @@ -199,40 +199,40 @@ # directories or you may have corrupted archives. # Enter here the list of databases to backup. # Wildcard: __ALL__ (will dump all the databases in one archive) -{{ config | manala_backup_manager_config_parameter('BM_MYSQL_DATABASES', default=['__ALL__']) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_MYSQL_DATABASES', default=['__ALL__']) }} # The best way to produce MySQL dump is done by using the "--opt" switch # of mysqldump. This make the dump directly usable with mysql (add the drop table # statements), lock the tables during the dump and other things. # This is recommended for full-clean-safe backups, but needs a # privileged user (for the lock permissions). -{{ config | manala_backup_manager_config_parameter('BM_MYSQL_SAFEDUMPS', default=True) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_MYSQL_SAFEDUMPS', default=True) }} # The user who is allowed to read every databases filled in BM_MYSQL_DATABASES -{{ config | manala_backup_manager_config_parameter('BM_MYSQL_ADMINLOGIN', default='root') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_MYSQL_ADMINLOGIN', default='root') }} # its password -{{ config | manala_backup_manager_config_parameter('BM_MYSQL_ADMINPASS', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_MYSQL_ADMINPASS', default='') }} # the host where the database is -{{ config | manala_backup_manager_config_parameter('BM_MYSQL_HOST', default='localhost') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_MYSQL_HOST', default='localhost') }} # the port where MySQL listen to on the host -{{ config | manala_backup_manager_config_parameter('BM_MYSQL_PORT', default=3306) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_MYSQL_PORT', default=3306) }} # which compression format to use? (gzip or bzip2) -{{ config | manala_backup_manager_config_parameter('BM_MYSQL_FILETYPE', default='bzip2') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_MYSQL_FILETYPE', default='bzip2') }} # Extra options to append to mysqldump # (take care to what you do; this will be silently added to the # command line.) -{{ config | manala_backup_manager_config_parameter('BM_MYSQL_EXTRA_OPTIONS', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_MYSQL_EXTRA_OPTIONS', default='') }} # Make separate backups of each database? -{{ config | manala_backup_manager_config_parameter('BM_MYSQL_SEPARATELY', default=True) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_MYSQL_SEPARATELY', default=True) }} # Specify DBs to exclude here (separated by space) -{{ config | manala_backup_manager_config_parameter('BM_MYSQL_DBEXCLUDE', default=[]) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_MYSQL_DBEXCLUDE', default=[]) }} ############################################################## # Backup method: PostgreSQL @@ -243,38 +243,38 @@ # directories or you may have corrupted archives. # Enter here the list of databases to backup. # Wildcard: __ALL__ (will dump all the databases in one archive) -{{ config | manala_backup_manager_config_parameter('BM_PGSQL_DATABASES', default=['__ALL__']) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_PGSQL_DATABASES', default=['__ALL__']) }} # The user who is allowed to read every databases filled in BM_PGSQL_DATABASES -{{ config | manala_backup_manager_config_parameter('BM_PGSQL_ADMINLOGIN', default='root') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_PGSQL_ADMINLOGIN', default='root') }} # its password -{{ config | manala_backup_manager_config_parameter('BM_PGSQL_ADMINPASS', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_PGSQL_ADMINPASS', default='') }} # the host where the database is -{{ config | manala_backup_manager_config_parameter('BM_PGSQL_HOST', default='localhost') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_PGSQL_HOST', default='localhost') }} # the port where PostgreSQL listen to on the host -{{ config | manala_backup_manager_config_parameter('BM_PGSQL_PORT', default=5432) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_PGSQL_PORT', default=5432) }} # which compression format to use? (gzip or bzip2) -{{ config | manala_backup_manager_config_parameter('BM_PGSQL_FILETYPE', default='bzip2') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_PGSQL_FILETYPE', default='bzip2') }} # Extra options to append to pg_dump # (take care to what you do; this will be silently added to the # command line.) -{{ config | manala_backup_manager_config_parameter('BM_PGSQL_EXTRA_OPTIONS', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_PGSQL_EXTRA_OPTIONS', default='') }} ############################################################## # Backup method: svn ############################################################# # Absolute paths to the svn repositories to archive -{{ config | manala_backup_manager_config_parameter('BM_SVN_REPOSITORIES', default=[]) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_SVN_REPOSITORIES', default=[]) }} # You can compress the resulting XML files # Supported compressor are: bzip2 and gzip -{{ config | manala_backup_manager_config_parameter('BM_SVN_COMPRESSWITH', default='bzip2') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_SVN_COMPRESSWITH', default='bzip2') }} ############################################################## # Backup method: pipe @@ -291,7 +291,7 @@ declare -a BM_PIPE_NAME declare -a BM_PIPE_FILETYPE declare -a BM_PIPE_COMPRESS -{{ config | manala_backup_manager_config_parameter('BM_PIPE', comment='# You can virtually implement whatever backup scenario you like +{{ config | manala.roles.backup_manager_config_parameter('BM_PIPE', comment='# You can virtually implement whatever backup scenario you like # with this method. # # The resulting archives will be named like this: @@ -338,13 +338,13 @@ export BM_PIPE_COMPRESS # If you don't want to use any upload method (you don't want to # upload files to remote hosts) then choose "none" -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_METHOD') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_METHOD', default=None) }} # where to upload (global to all methods. Not required to be set for S3) -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_HOSTS', default=[]) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_HOSTS', default=[]) }} # Where to put archives on the remote hosts (global) -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_DESTINATION', default='/var/archives/uploads') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_DESTINATION', default='/var/archives/uploads') }} # Uncomment the 'export ...' line below to activate the uploaded archives # database. @@ -365,28 +365,28 @@ export BM_PIPE_COMPRESS ############################################################# # the user to use for the SSH connections/transfers -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_SSH_USER', default='bmngr') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_SSH_USER', default='bmngr') }} # The private key to use for opening the connection -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_SSH_KEY', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_SSH_KEY', default='') }} # specific ssh hosts -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_SSH_HOSTS', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_SSH_HOSTS', default='') }} # port to use for SSH connections (leave blank for default one) -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_SSH_PORT', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_SSH_PORT', default='') }} # destination for ssh uploads (overrides BM_UPLOAD_DESTINATION) -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_SSH_DESTINATION', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_SSH_DESTINATION', default='') }} # purge archives on remote hosts before uploading? -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_SSH_PURGE', default=True) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_SSH_PURGE', default=True) }} # If you set BM_UPLOAD_SSH_PURGE, you can specify a time to live # for archives uploaded with SSH. # This can let you use different ttl's locally and remotely # By default, BM_ARCHIVE_TTL will be used. -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_SSH_TTL', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_SSH_TTL', default='') }} ############################################################## # The SSH-GPG method @@ -397,7 +397,7 @@ export BM_PIPE_COMPRESS # The gpg public key used for encryption, this can be a short # or long key id, or a descriptive name. See gpg man page for # all possibilities how to specify a key. -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_SSHGPG_RECIPIENT', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_SSHGPG_RECIPIENT', default='') }} ############################################################## # The FTP method @@ -406,41 +406,41 @@ export BM_PIPE_COMPRESS # Use FTP secured transfers (FTP over TLS) # User, password and data will be uploaded encrypted with SSL. # Passive mode will be automaticaly activated -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_FTP_SECURE', default=False) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_FTP_SECURE', default=False) }} # Do you want to use FTP passive mode? # This is mandatory for NATed/firewalled environments -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_FTP_PASSIVE', default=True) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_FTP_PASSIVE', default=True) }} # Timeout (in seconds) for FTP transfer # This setting only has effect when using FTP transfer with # secure mode disabled (BM_UPLOAD_FTP_SECURE to "false") -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_FTP_TIMEOUT', default=120) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_FTP_TIMEOUT', default=120) }} # Test the FTP connection before starting archives upload. # This will enable BM to try sending a 2MB test file before # sending any archive -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_FTP_TEST', default=False) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_FTP_TEST', default=False) }} # the user to use for the FTP connections/transfers -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_FTP_USER', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_FTP_USER', default='') }} # the FTP user's password -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_FTP_PASSWORD', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_FTP_PASSWORD', default='') }} # FTP specific remote hosts -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_FTP_HOSTS', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_FTP_HOSTS', default='') }} # purge archives on remote hosts before uploading? -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_FTP_PURGE', default=True) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_FTP_PURGE', default=True) }} # You can specify a time to live for archives uploaded with FTP # This can let you use different ttl's locally and remotely # By default, BM_ARCHIVE_TTL will be used. -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_FTP_TTL', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_FTP_TTL', default='') }} # destination for FTP uploads (overrides BM_UPLOAD_DESTINATION) -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_FTP_DESTINATION', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_FTP_DESTINATION', default='') }} ############################################################## @@ -451,56 +451,56 @@ export BM_PIPE_COMPRESS # account. See http://aws.amazon.com # The bucket to upload to. This bucket must be dedicated to backup-manager -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_S3_DESTINATION', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_S3_DESTINATION', default='') }} # the S3 access key provided to you -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_S3_ACCESS_KEY', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_S3_ACCESS_KEY', default='') }} # the S3 secret key provided to you -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_S3_SECRET_KEY', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_S3_SECRET_KEY', default='') }} # purge archives on remote hosts before uploading? -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_S3_PURGE', default=False) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_S3_PURGE', default=False) }} # You can specify a time to live for archives uploaded to S3 # This can let you use different ttl's locally and remotely # By default, BM_ARCHIVE_TTL will be used. -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_S3_TTL', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_S3_TTL', default='') }} ############################################################## # The RSYNC method ############################################################# # Which directories should be backuped with rsync -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_RSYNC_DIRECTORIES', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_RSYNC_DIRECTORIES', default='') }} # Destination for rsync uploads (overrides BM_UPLOAD_DESTINATION) -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_RSYNC_DESTINATION', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_RSYNC_DESTINATION', default='') }} # The list of remote hosts, if you want to enable the upload # system, just put some remote hosts here (fqdn or IPs) # Leave it empty if you want to use the hosts that are defined in # BM_UPLOAD_HOSTS -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_RSYNC_HOSTS', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_RSYNC_HOSTS', default='') }} # Do you want to dereference the files pointed by symlinks? # enter true or false (true can lead to huge archives, be careful). -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_RSYNC_DUMPSYMLINKS', default=False) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_RSYNC_DUMPSYMLINKS', default=False) }} # Files/folders to exclude when rsyncing. Warning: rsync will interpret # it as a mask, so will exclude any file/folder corresponding to it -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_RSYNC_BLACKLIST', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_RSYNC_BLACKLIST', default='') }} # Extra options to append to rsync # (take care to what you do; this will be silently added to the # command line.) -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_RSYNC_EXTRA_OPTIONS', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_RSYNC_EXTRA_OPTIONS', default='') }} # Do you want to limit the maximum available bandwidth rsync # can use ? # By default, no bandwidth limit is applied. # Example: 32M, 1024K, ... -{{ config | manala_backup_manager_config_parameter('BM_UPLOAD_RSYNC_BANDWIDTH_LIMIT', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_UPLOAD_RSYNC_BANDWIDTH_LIMIT', default='') }} ############################################################## # Section "BURNING" @@ -525,30 +525,30 @@ export BM_PIPE_COMPRESS # Note that if backup-manager is run from interactive prompt you # will be asked to insert disc(s) when needed -{{ config | manala_backup_manager_config_parameter('BM_BURNING_METHOD') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_BURNING_METHOD', default=None) }} # When the CD is burnt, it is possible to check every file's # MD5 checksum to see if the CD is not corrupted. -{{ config | manala_backup_manager_config_parameter('BM_BURNING_CHKMD5', default=False) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_BURNING_CHKMD5', default=False) }} # The device to use for mounting the cdrom -{{ config | manala_backup_manager_config_parameter('BM_BURNING_DEVICE', default='/dev/cdrom') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_BURNING_DEVICE', default='/dev/cdrom') }} # You can force cdrecord to use a specific device # Fill in the full path to the device to use or even # e.g. BM_BURNING_DEVFORCED="/dev/cdrom" # If none specified, the default cdrecord device will be used. -{{ config | manala_backup_manager_config_parameter('BM_BURNING_DEVFORCED', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_BURNING_DEVFORCED', default='') }} # By default backup-manager will make Joliet media (using the mkisofs switches # : "-R -J"). You can change these if you want to use non-Joliet disc images. # Change this only if you know what you're doing. Refer to mkisofs(8) for # details. -{{ config | manala_backup_manager_config_parameter('BM_BURNING_ISO_FLAGS', default='-R -J') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_BURNING_ISO_FLAGS', default='-R -J') }} # enter here the max size of your media # (usal sizes are 4200 for DVD media and 700 or 800 for CDR media) -{{ config | manala_backup_manager_config_parameter('BM_BURNING_MAXSIZE', default=650) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_BURNING_MAXSIZE', default=650) }} ############################################################## @@ -557,21 +557,21 @@ export BM_PIPE_COMPRESS # Every output made can be sent to syslog # set this to "true" or "false" -{{ config | manala_backup_manager_config_parameter('BM_LOGGER', default=True) }} +{{ config | manala.roles.backup_manager_config_parameter('BM_LOGGER', default=True) }} # Which level of messages do you want to log to syslog? # possible values are : debug,info,warning,error -{{ config | manala_backup_manager_config_parameter('BM_LOGGER_LEVEL', default='warning') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_LOGGER_LEVEL', default='warning') }} # You can choose which facility to use -{{ config | manala_backup_manager_config_parameter('BM_LOGGER_FACILITY', default='user') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_LOGGER_FACILITY', default='user') }} # Enter here some shell script. # It will be executed before the first action of backup-manager. -{{ config | manala_backup_manager_config_parameter('BM_PRE_BACKUP_COMMAND', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_PRE_BACKUP_COMMAND', default='') }} # Enter here some shell script. # It will be executed after the last action of backup-manager. -{{ config | manala_backup_manager_config_parameter('BM_POST_BACKUP_COMMAND', default='') }} +{{ config | manala.roles.backup_manager_config_parameter('BM_POST_BACKUP_COMMAND', default='') }} {% endif -%} diff --git a/roles/backup_manager/templates/configs/mysql.j2 b/roles/backup_manager/templates/configs/mysql.j2 deleted file mode 100644 index 6d7da03d3..000000000 --- a/roles/backup_manager/templates/configs/mysql.j2 +++ /dev/null @@ -1,7 +0,0 @@ -{#- Deprecated -#} - -{%- set config_default = { - 'BM_ARCHIVE_METHOD': 'mysql' -} -%} - -{% include '_base.j2' %} diff --git a/roles/backup_manager/templates/configs/pgsql.j2 b/roles/backup_manager/templates/configs/pgsql.j2 deleted file mode 100644 index ce101d788..000000000 --- a/roles/backup_manager/templates/configs/pgsql.j2 +++ /dev/null @@ -1,7 +0,0 @@ -{#- Deprecated -#} - -{%- set config_default = { - 'BM_ARCHIVE_METHOD': 'pgsql' -} -%} - -{% include '_base.j2' %} diff --git a/roles/backup_manager/tests/.gitignore b/roles/backup_manager/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/backup_manager/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/backup_manager/tests/0000_default.goss.yml b/roles/backup_manager/tests/0000_default.goss.yml deleted file mode 100644 index fdea30827..000000000 --- a/roles/backup_manager/tests/0000_default.goss.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- - -package: - backup-manager: - installed: true - -command: - dpkg -s backup-manager: - exit-status: 0 - stdout: -{{ if eq .Env.DISTRIBUTION_RELEASE "jessie" "stretch" }} - - "/^Version: .*manala\\d~{{ .Env.DISTRIBUTION_RELEASE }}\\d+$/" -{{ else }} - - "/^Version: \\d+/" -{{ end }} - backup-manager --version: - exit-status: 0 - stdout: - - Backup Manager diff --git a/roles/backup_manager/tests/0000_default.yml b/roles/backup_manager/tests/0000_default.yml deleted file mode 100644 index 82904f987..000000000 --- a/roles/backup_manager/tests/0000_default.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/manala.yml - when: ansible_distribution_release in ['jessie', 'stretch'] - - - block: - - import_role: - name: manala.backup_manager - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/backup_manager/tests/0200_configs.goss.yml b/roles/backup_manager/tests/0200_configs.goss.yml deleted file mode 100644 index 4dcc3790c..000000000 --- a/roles/backup_manager/tests/0200_configs.goss.yml +++ /dev/null @@ -1,146 +0,0 @@ ---- - -# Default -{{ if has "default" .Vars.tags }} -file: - tmp/configs/default: - exists: true - filetype: directory - owner: root - group: root - mode: "0700" - tmp/configs/default/default.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - contains: - - export BM_REPOSITORY_ROOT="/srv/backup/mysql" - - export BM_TARBALL_DIRECTORIES="foo bar baz" - - BM_PIPE_COMMAND[0]="command0" - - BM_PIPE_NAME[0]="name0" - - BM_PIPE_FILETYPE[0]="filetype0" - - BM_PIPE_COMPRESS[0]="compress0" - - BM_PIPE_COMMAND[1]="command1" - - BM_PIPE_NAME[1]="name1" - - BM_PIPE_FILETYPE[1]="filetype1" - - BM_PIPE_COMPRESS[1]="compress1" - tmp/configs/default/default_deprecated.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - contains: - - export BM_REPOSITORY_ROOT="/srv/backup/mysql" - - export BM_TARBALL_DIRECTORIES="foo bar baz" - - BM_PIPE_COMMAND[0]="command0" - - BM_PIPE_NAME[0]="name0" - - BM_PIPE_FILETYPE[0]="filetype0" - - BM_PIPE_COMPRESS[0]="compress0" - - BM_PIPE_COMMAND[1]="command1" - - BM_PIPE_NAME[1]="name1" - - BM_PIPE_FILETYPE[1]="filetype1" - - BM_PIPE_COMPRESS[1]="compress1" - tmp/configs/default/default_content.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - contains: - - export BM_REPOSITORY_ROOT="/srv/backup/mysql" - - export BM_TARBALL_DIRECTORIES="foo bar baz" - - BM_PIPE_COMMAND[0]="command0" - - BM_PIPE_NAME[0]="name0" - - BM_PIPE_FILETYPE[0]="filetype0" - - BM_PIPE_COMPRESS[0]="compress0" - - BM_PIPE_COMMAND[1]="command1" - - BM_PIPE_NAME[1]="name1" - - BM_PIPE_FILETYPE[1]="filetype1" - - BM_PIPE_COMPRESS[1]="compress1" - tmp/configs/default/template.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - contains: - - "Configs foo" -{{ end }} - -# State -{{ if has "state" .Vars.tags }} -file: - tmp/configs/state/foo.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - size: 1 - tmp/configs/state/bar.conf: - exists: false - tmp/configs/state/baz.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - size: 1 - tmp/configs/state/qux.conf: - exists: true - filetype: file - tmp/configs/state/quux.conf: - exists: false -{{ end }} - -# Defaults -{{ if has "defaults" .Vars.tags }} -file: - tmp/configs/defaults/foo.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - contains: - - "Configs foo" - tmp/configs/defaults/bar.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - contains: - - "Configs bar" - tmp/configs/defaults/baz.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - contains: - - "Configs bar" -{{ end }} - -# Exclusive -{{ if has "exclusive" .Vars.tags }} -file: - tmp/configs/exclusive/foo.conf: - exists: false - tmp/configs/exclusive/bar.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - size: 1 - tmp/configs/exclusive/baz.conf: - exists: false - tmp/configs/exclusive/qux.conf: - exists: false - tmp/configs/exclusive/quux.conf: - exists: false -{{ end }} diff --git a/roles/backup_manager/tests/0200_configs.yml b/roles/backup_manager/tests/0200_configs.yml deleted file mode 100644 index 917d4fa4b..000000000 --- a/roles/backup_manager/tests/0200_configs.yml +++ /dev/null @@ -1,166 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - tags: [always] - block: - - import_tasks: pre_tasks/manala.yml - when: ansible_distribution_release in ['jessie', 'stretch'] - - # Default - - tags: [default] - block: - - file: - path: tmp/configs/default - state: absent - - import_role: - # Play role fully on first run, so that handlers don't breaks - name: manala.backup_manager - vars: - manala_backup_manager_configs_dir: tmp/configs/default - manala_backup_manager_configs: - # Default - - file: default.conf - config: - BM_REPOSITORY_ROOT: /srv/backup/mysql - BM_TARBALL_DIRECTORIES: - - foo - - bar - # Flatten - - - - baz - BM_PIPE: - - COMMAND: command0 - NAME: name0 - FILETYPE: filetype0 - COMPRESS: compress0 - - COMMAND: command1 - NAME: name1 - FILETYPE: filetype1 - COMPRESS: compress1 - # Default - Deprecated - - file: default_deprecated.conf - config: - - BM_REPOSITORY_ROOT: /srv/backup/mysql - - BM_TARBALL_DIRECTORIES: - - foo - - bar - # Flatten - - - - baz - - BM_PIPE: - - COMMAND: command0 - NAME: name0 - FILETYPE: filetype0 - COMPRESS: compress0 - - COMMAND: command1 - NAME: name1 - FILETYPE: filetype1 - COMPRESS: compress1 - # Default - Content - - file: default_content.conf - config: | - export BM_REPOSITORY_ROOT="/srv/backup/mysql" - export BM_TARBALL_DIRECTORIES="foo bar baz" - BM_PIPE_COMMAND[0]="command0" - BM_PIPE_NAME[0]="name0" - BM_PIPE_FILETYPE[0]="filetype0" - BM_PIPE_COMPRESS[0]="compress0" - BM_PIPE_COMMAND[1]="command1" - BM_PIPE_NAME[1]="name1" - BM_PIPE_FILETYPE[1]="filetype1" - BM_PIPE_COMPRESS[1]="compress1" - # Flatten - - - # Template - - file: template.conf - template: configs/foo.conf.j2 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [default]}" validate - - # State - - tags: [state] - block: - - file: - path: tmp/configs/state - state: "{{ item }}" - loop: [absent, directory] - - file: - path: tmp/configs/state/{{ item }}.conf - state: touch - loop: [bar, qux] - - import_role: - name: manala.backup_manager - tasks_from: configs - vars: - manala_backup_manager_configs_dir: tmp/configs/state - manala_backup_manager_configs: - - file: foo.conf - - file: bar.conf - state: absent - - file: baz.conf - state: present - - file: qux.conf - state: ignore - - file: quux.conf - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [state]}" validate - - # Defaults - - tags: [defaults] - block: - - file: - path: tmp/configs/defaults - state: absent - - import_role: - name: manala.backup_manager - tasks_from: configs - vars: - manala_backup_manager_configs_dir: tmp/configs/defaults - manala_backup_manager_configs_defaults: - template: configs/foo.conf.j2 - manala_backup_manager_configs: - - file: foo.conf - - template: configs/bar.conf.j2 - - file: baz.conf - template: configs/bar.conf.j2 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [defaults]}" validate - - # Exclusive - - tags: [exclusive] - block: - - file: - path: tmp/configs/exclusive - state: "{{ item }}" - loop: [absent, directory] - - file: - path: tmp/configs/exclusive/{{ item }}.conf - state: touch - loop: [foo, bar, baz, qux] - - import_role: - name: manala.backup_manager - tasks_from: configs - vars: - manala_backup_manager_configs_dir: tmp/configs/exclusive - manala_backup_manager_configs_exclusive: true - manala_backup_manager_configs: - - file: bar.conf - - file: qux.conf - state: ignore - - file: quux.conf - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [exclusive]}" validate diff --git a/roles/backup_manager/tests/pre_tasks/apt_keys/manala.pgp b/roles/backup_manager/tests/pre_tasks/apt_keys/manala.pgp deleted file mode 100644 index 7ddda1520..000000000 --- a/roles/backup_manager/tests/pre_tasks/apt_keys/manala.pgp +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1 - -mQENBFbnzV0BCACdvQQktxEJdf7G85ZAXi9cQwA48leIVmxqikwR4hbvrNaanu6T -ySh1l0vKQblKAFvntPUhubX5WSeJ/Q0HoQHw7KqCgiaa+R2N5hK8JfkZxaX6/lIN -v5IVVke7Xv2oypONjUMcjDqGIWNQLP0ULCoEMD20KAYiKDlex32PrHJZajtUUZCE -stAzuMpVD0wsTOHUiXpNUlBjILOjI2dFf0X2sqzIJyVY7nx+9SPJShE5seKlcmS+ -UV1zQasMT1gU2R+WznXt5fLP/vBB6w+7cLkSyLcE615wk7trt3HBVgmBt0P8DXGw -nnxwQvmVCT4GZuuYTFAedFRRP9DziJDUTSBlABEBAAG0Gk1hbmFsYSA8Y29udGFj -dEBtYW5hbGEuaW8+iQE4BBMBAgAiBQJW581dAhsDBgsJCAcDAgYVCAIJCgsEFgID -AQIeAQIXgAAKCRCp6Eh4E5Teo+HpB/4r/5dsn9/smd0CoGsV818FICq8p2RhUX+a -X5vqIqcFZpCGEnvT0ipcOVL3Ftl108q92lv//npCvWcN51acw9+3bjsmMkxucw6q -TdxG9b/y8+LZ3OyUAxNqT6jvZIa7JT8nTJKMHeY01N0MKmofIoBO/WxQSi9OggI8 -RfdXmXTndYLGNC9jL9qWvsGFpugtjqUkhSiTySSRlu959QzGMtuqz26CKOCx5IiG -CmXYNRFdxrrdk4jhNkFMtnOTur7M39rnZTyZ6B4yHgrraqyIQRRKHMPMWBVOtL0K -Motcf3NjtN+0FyASwhZa2cQREJQ2wxI6S+8bbvaSCr1TNBQlCuxZuQENBFbnzV0B -CACmfjoB5nr0aIJqtjT2m8YdefVA13UcSWo2ECHNqQALQ+Mz8AUgG/iO45XazhWo -6acVhC6rrskokUMss4NQeXZZqlujPfySp8gYMsdQV5VtPnMBrU3tCpFYBbgjfb4s -/f0bs6Wo/evuKzQxV+sjKrq/NrCmKFf8mjA9NmjOvA5BbWf4CDnAGmqahksEQwmV -QBZ4oFl0t2gLkyT6FQn5oolQuivzXuKBDCrDdgLtOwYYeZmRgVKMSvs1FtSTR/uR -m3Tbc5zulQLF0RfvIpxseMJtmEf4Znnmk0b0KBfwnoD6sx2ynNGJEUphdP0JmJn2 -xPU0HEnAcQZQaSJpYcX007JBABEBAAGJAR8EGAECAAkFAlbnzV0CGwwACgkQqehI -eBOU3qOc0wf/QKvTldOfieDOQ9C5uBRWcAxfTkTQPLSjLF+cTh5ujbCTDiwf0aEN -OPtRsjC6Pc/sCGLCXvT3HiAZSc3/LNadlhUbi6nvoQf+XFSl++wQ423iDNrLUmi9 -/ZQS6hti79jdvk9pIE8ja4VddY5m+cOBoraC0tcSn8L1TZocklfFSfNUzY3+yY8A -1cQyrSCvpsETBsgRjj7RVhOQx5XDPPKpN9rp/Y4MIPF0PLARrqjG3sVbKmUt5TTf -GmAPbrVtxesgF9ZhUC8EZnfsI1oSkPM3nlYEnHJC2E5tM0mF3h4JOVZgJk5NrxGq -OSbTmRZCQBJF0871MKJdKzEzLI/Y/3nIjg== -=K9mA ------END PGP PUBLIC KEY BLOCK----- diff --git a/roles/backup_manager/tests/pre_tasks/manala.yml b/roles/backup_manager/tests/pre_tasks/manala.yml deleted file mode 100644 index fc107f04c..000000000 --- a/roles/backup_manager/tests/pre_tasks/manala.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Pre tasks > Manala apt key - apt_key: - file: pre_tasks/apt_keys/manala.pgp - id: 1394DEA3 - -- name: Pre tasks > Manala apt repository - apt_repository: - repo: deb [arch=amd64] http://debian.manala.io {{ ansible_distribution_release }} main diff --git a/roles/backup_manager/tests/templates/configs/bar.conf.j2 b/roles/backup_manager/tests/templates/configs/bar.conf.j2 deleted file mode 100644 index 53e654354..000000000 --- a/roles/backup_manager/tests/templates/configs/bar.conf.j2 +++ /dev/null @@ -1 +0,0 @@ -Configs bar diff --git a/roles/backup_manager/tests/templates/configs/foo.conf.j2 b/roles/backup_manager/tests/templates/configs/foo.conf.j2 deleted file mode 100644 index cdc34797b..000000000 --- a/roles/backup_manager/tests/templates/configs/foo.conf.j2 +++ /dev/null @@ -1 +0,0 @@ -Configs foo diff --git a/roles/backup_manager/tests/tmp/.gitignore b/roles/backup_manager/tests/tmp/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/roles/backup_manager/tests/tmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/roles/beanstalkd/.gitignore b/roles/beanstalkd/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/beanstalkd/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/beanstalkd/.manala/make/Makefile b/roles/beanstalkd/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/beanstalkd/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/beanstalkd/.manala/make/Makefile.docker b/roles/beanstalkd/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/beanstalkd/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/beanstalkd/.manala/make/Makefile.host b/roles/beanstalkd/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/beanstalkd/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/beanstalkd/.manala/make/Makefile.manala b/roles/beanstalkd/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/beanstalkd/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/beanstalkd/.manala/make/Makefile.travis b/roles/beanstalkd/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/beanstalkd/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/beanstalkd/.manala/make/gmsl/__gmsl b/roles/beanstalkd/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/beanstalkd/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/beanstalkd/.manala/make/gmsl/gmsl b/roles/beanstalkd/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/beanstalkd/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/beanstalkd/.travis.yml b/roles/beanstalkd/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/beanstalkd/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/beanstalkd/CHANGELOG.md b/roles/beanstalkd/CHANGELOG.md deleted file mode 100644 index f95c1c0d1..000000000 --- a/roles/beanstalkd/CHANGELOG.md +++ /dev/null @@ -1,45 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.2] - 2020-08-28 -### Changed -- Explicit file permissions - -## [2.0.1] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.4] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.3] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.2] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.0] - 2017-06-09 -### Added -- Handle installation -- Handle config -- Handle services diff --git a/roles/beanstalkd/Makefile b/roles/beanstalkd/Makefile deleted file mode 100644 index 2903402bc..000000000 --- a/roles/beanstalkd/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.beanstalkd -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/beanstalkd/README.md b/roles/beanstalkd/README.md deleted file mode 100644 index 0e9e5daa0..000000000 --- a/roles/beanstalkd/README.md +++ /dev/null @@ -1,73 +0,0 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated. - -### You can find our other roles in the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Beanstalkd [![Build Status](https://travis-ci.org/manala/ansible-role-beanstalkd.svg?branch=master)](https://travis-ci.org/manala/ansible-role-beanstalkd) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: - -This role will deal with the setup of [Beanstalkd](http://kr.github.io/beanstalkd/). - -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. - -## Requirements - -None. - -## Dependencies - -None. - -## Installation - -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.beanstalkd -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.beanstalkd -``` - -## Role Handlers - -None. - -## Role Variables - -### Definition - -| Name | Default | Type | Description | -| -------------------------------------------- | ------------------------- | ------ | -------------------------------------- | -| `manala_beanstalkd_install_packages` | ~ | Array | Dependency packages to install | -| `manala_beanstalkd_install_packages_default` | ['beanstalkd'] | Array | Default dependency packages to install | -| `manala_beanstalkd_config_file` | '/etc/default/beanstalkd' | String | Config file path | -| `manala_beanstalkd_config_template` | ~ | String | Config template path | -| `manala_beanstalkd_config` | [] | Array | Config | - -### Example - -```yaml -- hosts: all - roles: - - role: manala.beanstalkd -``` - -# Licence - -MIT - -# Author information - -Manala [**(http://www.manala.io/)**](http://www.manala.io) diff --git a/roles/beanstalkd/defaults/main.yml b/roles/beanstalkd/defaults/main.yml deleted file mode 100644 index 239fb1711..000000000 --- a/roles/beanstalkd/defaults/main.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- - -# Install -manala_beanstalkd_install_packages: ~ -manala_beanstalkd_install_packages_default: - - beanstalkd - -# Config -manala_beanstalkd_config_file: /etc/default/beanstalkd -manala_beanstalkd_config_template: ~ -manala_beanstalkd_config: [] diff --git a/roles/beanstalkd/handlers/main.yml b/roles/beanstalkd/handlers/main.yml deleted file mode 100644 index 10d6dd080..000000000 --- a/roles/beanstalkd/handlers/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -- name: beanstalkd restart - service: - name: beanstalkd - state: restarted diff --git a/roles/beanstalkd/meta/main.yml b/roles/beanstalkd/meta/main.yml deleted file mode 100644 index 660395b7b..000000000 --- a/roles/beanstalkd/meta/main.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- - -dependencies: [] - -galaxy_info: - - role_name: beanstalkd - author: Manala - company: Manala - description: Handle beanstalkd - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues - platforms: - - name: Debian - versions: - - jessie - - stretch - - buster - galaxy_tags: - - system - - beanstalkd diff --git a/roles/beanstalkd/tasks/config.yml b/roles/beanstalkd/tasks/config.yml deleted file mode 100644 index 09be1b5f6..000000000 --- a/roles/beanstalkd/tasks/config.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -- name: config > Template - template: - src: "{{ - manala_beanstalkd_config_template|ternary( - manala_beanstalkd_config_template, - 'config/' ~ ansible_distribution|lower ~ '_' ~ ansible_distribution_release ~ '.j2' - ) - }}" - dest: "{{ manala_beanstalkd_config_file }}" - owner: root - group: root - mode: "0644" - when: (manala_beanstalkd_config_template is not none) or (manala_beanstalkd_config|length) - notify: - - beanstalkd restart diff --git a/roles/beanstalkd/tasks/install.yml b/roles/beanstalkd/tasks/install.yml deleted file mode 100644 index bf85b0fbe..000000000 --- a/roles/beanstalkd/tasks/install.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- name: install > Packages - apt: - name: "{{ manala_beanstalkd_install_packages|default(manala_beanstalkd_install_packages_default, True) }}" - install_recommends: false - update_cache: true - cache_valid_time: 3600 diff --git a/roles/beanstalkd/tasks/main.yml b/roles/beanstalkd/tasks/main.yml deleted file mode 100644 index 44fecd70f..000000000 --- a/roles/beanstalkd/tasks/main.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -# Install -- import_tasks: install.yml - tags: - - manala_beanstalkd - - manala_beanstalkd.install - -# Config -- import_tasks: config.yml - tags: - - manala_beanstalkd - - manala_beanstalkd.config - -# Services -- import_tasks: services.yml - tags: - - manala_beanstalkd - - manala_beanstalkd.services - - manala.services diff --git a/roles/beanstalkd/tasks/services.yml b/roles/beanstalkd/tasks/services.yml deleted file mode 100644 index f207bf21b..000000000 --- a/roles/beanstalkd/tasks/services.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- name: services > Services - service: - name: "{{ item }}" - state: started - with_items: - - beanstalkd diff --git a/roles/beanstalkd/templates/config/_macros.j2 b/roles/beanstalkd/templates/config/_macros.j2 deleted file mode 100644 index 9a001aea5..000000000 --- a/roles/beanstalkd/templates/config/_macros.j2 +++ /dev/null @@ -1,64 +0,0 @@ -{%- macro config(parameters, exclusions = []) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value) }}{{ '\n' }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value) -%} - {%- if value is sequence and value is not string -%} - {{ ('"' ~ key ~ '"') }}: {{ '{\n' }}{{ config(value, []) }}{{ '}' }} - {%- else -%} - {{ _config_parameter_key(key) }}={{ _config_parameter_value(value) }} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - {{ key }} -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {%- if value is sameas none -%} - {%- elif value is sameas true -%} - yes - {%- elif value is sameas false -%} - no - {%- elif value is string -%} - "{{ value }}" - {%- elif value is number -%} - {{ value }} - {%- endif -%} -{%- endmacro -%} diff --git a/roles/beanstalkd/templates/config/debian_buster.j2 b/roles/beanstalkd/templates/config/debian_buster.j2 deleted file mode 100644 index 01bcc25e3..000000000 --- a/roles/beanstalkd/templates/config/debian_buster.j2 +++ /dev/null @@ -1,20 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{%- set config = manala_beanstalkd_config -%} - -## Defaults for the beanstalkd init script, /etc/init.d/beanstalkd on -## Debian systems. - -{{ macros.config_row(config, 'BEANSTALKD_LISTEN_ADDR', '127.0.0.1') }} -{{ macros.config_row(config, 'BEANSTALKD_LISTEN_PORT', 11300) }} - -# You can use BEANSTALKD_EXTRA to pass additional options. See beanstalkd(1) -# for a list of the available options. Uncomment the following line for -# persistent job storage. -{{ macros.config_row(config, 'BEANSTALKD_EXTRA', '#BEANSTALKD_EXTRA="-b /var/lib/beanstalkd"', true) }} - -{{ macros.config(config, [ - 'BEANSTALKD_LISTEN_ADDR', - 'BEANSTALKD_LISTEN_PORT', - 'BEANSTALKD_EXTRA' -]) }} diff --git a/roles/beanstalkd/templates/config/debian_jessie.j2 b/roles/beanstalkd/templates/config/debian_jessie.j2 deleted file mode 100644 index 01bcc25e3..000000000 --- a/roles/beanstalkd/templates/config/debian_jessie.j2 +++ /dev/null @@ -1,20 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{%- set config = manala_beanstalkd_config -%} - -## Defaults for the beanstalkd init script, /etc/init.d/beanstalkd on -## Debian systems. - -{{ macros.config_row(config, 'BEANSTALKD_LISTEN_ADDR', '127.0.0.1') }} -{{ macros.config_row(config, 'BEANSTALKD_LISTEN_PORT', 11300) }} - -# You can use BEANSTALKD_EXTRA to pass additional options. See beanstalkd(1) -# for a list of the available options. Uncomment the following line for -# persistent job storage. -{{ macros.config_row(config, 'BEANSTALKD_EXTRA', '#BEANSTALKD_EXTRA="-b /var/lib/beanstalkd"', true) }} - -{{ macros.config(config, [ - 'BEANSTALKD_LISTEN_ADDR', - 'BEANSTALKD_LISTEN_PORT', - 'BEANSTALKD_EXTRA' -]) }} diff --git a/roles/beanstalkd/templates/config/debian_stretch.j2 b/roles/beanstalkd/templates/config/debian_stretch.j2 deleted file mode 100644 index 01bcc25e3..000000000 --- a/roles/beanstalkd/templates/config/debian_stretch.j2 +++ /dev/null @@ -1,20 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{%- set config = manala_beanstalkd_config -%} - -## Defaults for the beanstalkd init script, /etc/init.d/beanstalkd on -## Debian systems. - -{{ macros.config_row(config, 'BEANSTALKD_LISTEN_ADDR', '127.0.0.1') }} -{{ macros.config_row(config, 'BEANSTALKD_LISTEN_PORT', 11300) }} - -# You can use BEANSTALKD_EXTRA to pass additional options. See beanstalkd(1) -# for a list of the available options. Uncomment the following line for -# persistent job storage. -{{ macros.config_row(config, 'BEANSTALKD_EXTRA', '#BEANSTALKD_EXTRA="-b /var/lib/beanstalkd"', true) }} - -{{ macros.config(config, [ - 'BEANSTALKD_LISTEN_ADDR', - 'BEANSTALKD_LISTEN_PORT', - 'BEANSTALKD_EXTRA' -]) }} diff --git a/roles/beanstalkd/templates/config/default.dev.j2 b/roles/beanstalkd/templates/config/default.dev.j2 deleted file mode 100644 index 451b2d18f..000000000 --- a/roles/beanstalkd/templates/config/default.dev.j2 +++ /dev/null @@ -1,26 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{%- set config = manala_beanstalkd_config -%} - -## Defaults for the beanstalkd init script, /etc/init.d/beanstalkd on -## Debian systems. Append ``-b /var/lib/beanstalkd'' for persistent -## storage. - -{{ macros.config_row(config, 'BEANSTALKD_LISTEN_ADDR', '0.0.0.0') }} -{{ macros.config_row(config, 'BEANSTALKD_LISTEN_PORT', 11300) }} -{{ macros.config_row(config, 'DAEMON_OPTS', '-l $BEANSTALKD_LISTEN_ADDR -p $BEANSTALKD_LISTEN_PORT $BEANSTALKD_EXTRA') }} - -# You can use BEANSTALKD_EXTRA to pass additional options. See beanstalkd(1) -# for a list of the available options. Uncomment the following line for -# persistent job storage. -{{ macros.config_row(config, 'BEANSTALKD_EXTRA', '#BEANSTALKD_EXTRA="-b /var/lib/beanstalkd"', true) }} - -{{ macros.config_row(config, 'START', true) }} - -{{ macros.config(config, [ - 'BEANSTALKD_LISTEN_ADDR', - 'BEANSTALKD_LISTEN_PORT', - 'DAEMON_OPTS', - 'BEANSTALKD_EXTRA', - 'START' -]) }} diff --git a/roles/beanstalkd/templates/config/default.prod.j2 b/roles/beanstalkd/templates/config/default.prod.j2 deleted file mode 100644 index 7b9a68c28..000000000 --- a/roles/beanstalkd/templates/config/default.prod.j2 +++ /dev/null @@ -1,26 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{%- set config = manala_beanstalkd_config -%} - -## Defaults for the beanstalkd init script, /etc/init.d/beanstalkd on -## Debian systems. Append ``-b /var/lib/beanstalkd'' for persistent -## storage. - -{{ macros.config_row(config, 'BEANSTALKD_LISTEN_ADDR', '127.0.0.1') }} -{{ macros.config_row(config, 'BEANSTALKD_LISTEN_PORT', 11300) }} -{{ macros.config_row(config, 'DAEMON_OPTS', '-l $BEANSTALKD_LISTEN_ADDR -p $BEANSTALKD_LISTEN_PORT $BEANSTALKD_EXTRA') }} - -# You can use BEANSTALKD_EXTRA to pass additional options. See beanstalkd(1) -# for a list of the available options. Uncomment the following line for -# persistent job storage. -{{ macros.config_row(config, 'BEANSTALKD_EXTRA', '#BEANSTALKD_EXTRA="-b /var/lib/beanstalkd"', true) }} - -{{ macros.config_row(config, 'START', true) }} - -{{ macros.config(config, [ - 'BEANSTALKD_LISTEN_ADDR', - 'BEANSTALKD_LISTEN_PORT', - 'DAEMON_OPTS', - 'BEANSTALKD_EXTRA', - 'START' -]) }} diff --git a/roles/beanstalkd/templates/config/default.test.j2 b/roles/beanstalkd/templates/config/default.test.j2 deleted file mode 100644 index 451b2d18f..000000000 --- a/roles/beanstalkd/templates/config/default.test.j2 +++ /dev/null @@ -1,26 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{%- set config = manala_beanstalkd_config -%} - -## Defaults for the beanstalkd init script, /etc/init.d/beanstalkd on -## Debian systems. Append ``-b /var/lib/beanstalkd'' for persistent -## storage. - -{{ macros.config_row(config, 'BEANSTALKD_LISTEN_ADDR', '0.0.0.0') }} -{{ macros.config_row(config, 'BEANSTALKD_LISTEN_PORT', 11300) }} -{{ macros.config_row(config, 'DAEMON_OPTS', '-l $BEANSTALKD_LISTEN_ADDR -p $BEANSTALKD_LISTEN_PORT $BEANSTALKD_EXTRA') }} - -# You can use BEANSTALKD_EXTRA to pass additional options. See beanstalkd(1) -# for a list of the available options. Uncomment the following line for -# persistent job storage. -{{ macros.config_row(config, 'BEANSTALKD_EXTRA', '#BEANSTALKD_EXTRA="-b /var/lib/beanstalkd"', true) }} - -{{ macros.config_row(config, 'START', true) }} - -{{ macros.config(config, [ - 'BEANSTALKD_LISTEN_ADDR', - 'BEANSTALKD_LISTEN_PORT', - 'DAEMON_OPTS', - 'BEANSTALKD_EXTRA', - 'START' -]) }} diff --git a/roles/beanstalkd/tests/.gitignore b/roles/beanstalkd/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/beanstalkd/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/beanstalkd/tests/0100_install.goss.yml b/roles/beanstalkd/tests/0100_install.goss.yml deleted file mode 100644 index 4e57e168d..000000000 --- a/roles/beanstalkd/tests/0100_install.goss.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- - -package: - beanstalkd: - installed: true diff --git a/roles/beanstalkd/tests/0100_install.yml b/roles/beanstalkd/tests/0100_install.yml deleted file mode 100644 index 59d508bbb..000000000 --- a/roles/beanstalkd/tests/0100_install.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - roles: - - manala.beanstalkd - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/beanstalkd/tests/0200_config.goss.yml b/roles/beanstalkd/tests/0200_config.goss.yml deleted file mode 100644 index 594815ac6..000000000 --- a/roles/beanstalkd/tests/0200_config.goss.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- - -file: - /etc/default/beanstalkd.test: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - BEANSTALKD_LISTEN_PORT=12345 diff --git a/roles/beanstalkd/tests/0200_config.yml b/roles/beanstalkd/tests/0200_config.yml deleted file mode 100644 index 3a7577e82..000000000 --- a/roles/beanstalkd/tests/0200_config.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_beanstalkd_config_file: /etc/default/beanstalkd.test - manala_beanstalkd_config: - - BEANSTALKD_LISTEN_PORT: 12345 - roles: - - manala.beanstalkd - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/beanstalkd/tests/0300_services.goss.yml b/roles/beanstalkd/tests/0300_services.goss.yml deleted file mode 100644 index 166c08bc2..000000000 --- a/roles/beanstalkd/tests/0300_services.goss.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -service: - beanstalkd: - enabled: true - running: true diff --git a/roles/beanstalkd/tests/0300_services.yml b/roles/beanstalkd/tests/0300_services.yml deleted file mode 100644 index 59d508bbb..000000000 --- a/roles/beanstalkd/tests/0300_services.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - roles: - - manala.beanstalkd - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/bind/.gitignore b/roles/bind/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/bind/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/bind/.manala/make/Makefile b/roles/bind/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/bind/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/bind/.manala/make/Makefile.docker b/roles/bind/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/bind/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/bind/.manala/make/Makefile.host b/roles/bind/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/bind/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/bind/.manala/make/Makefile.manala b/roles/bind/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/bind/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/bind/.manala/make/Makefile.travis b/roles/bind/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/bind/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/bind/.manala/make/gmsl/__gmsl b/roles/bind/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/bind/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/bind/.manala/make/gmsl/gmsl b/roles/bind/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/bind/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/bind/.travis.yml b/roles/bind/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/bind/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/bind/CHANGELOG.md b/roles/bind/CHANGELOG.md deleted file mode 100644 index 8e316aa53..000000000 --- a/roles/bind/CHANGELOG.md +++ /dev/null @@ -1,63 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.2] - 2020-06-09 -### Changed -- Install dependencies based on python version - -## [2.0.1] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.4] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.3] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Replace deprecated jinja tests used as filters -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.2] - 2018-03-16 -### Added -- Handle options -- Handle dynamic zones records -- Configs/Zones now supports raw `content` parameter in addition of `template` -- Configs/Zones now supports `state` parameter (present|absent) -- Configs/Zones now supports `omit` parameter (false|true) -- Zones now supports `zone` parameter (serves among other things to generate `file` parameter) -- `manala_bind_zone_file` filter to standardize zone file names - -### Changed -- Default zones dir set to `/var/cache/bind` -- Zones directory owner is now set to `root` -- Zones files owner is now set to `{{ manala_bind_user }}` - -### Removed -- Zones directory is not created anymore -- Reload handler - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.0] - 2017-06-21 -### Added -- Handle installation -- Handle logs -- Handle configs -- Handle zones -- Handle services diff --git a/roles/bind/Makefile b/roles/bind/Makefile deleted file mode 100644 index cbf8d2f36..000000000 --- a/roles/bind/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.bind -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/bind/README.md b/roles/bind/README.md index 72d78812a..6a51d880a 100644 --- a/roles/bind/README.md +++ b/roles/bind/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Bind [![Build Status](https://travis-ci.org/manala/ansible-role-bind.svg?branch=master)](https://travis-ci.org/manala/ansible-role-bind) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Bind This role will deal with the setup of [Bind](https://www.isc.org/downloads/bind/). -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,19 +14,7 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.bind -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.bind -``` +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Filters @@ -48,18 +24,7 @@ Using ansible galaxy requirements file: ## Role Variables -| Name | Default | Type | Description | -| -------------------------------------- | ----------------------------- | ------ | -------------------------------------- | -| `manala_bind_install_packages` | ~ | Array | Dependency packages to install | -| `manala_bind_install_packages_default` | ['bind9'] | Array | Default dependency packages to install | -| `manala_bind_user` | 'bind' | String | User | -| `manala_bind_group` | 'bind' | String | Group | -| `manala_bind_options` | ['-u {{ manala_bind_user }}'] | Array | Options | -| `manala_bind_log_dir` | '/var/log/bind' | String | Log dir | -| `manala_bind_configs` | [] | Array | List of config files | -| `manala_bind_configs_dir` | '/etc/bind' | String | Config files directory | -| `manala_bind_zones_dir` | '/var/cache/bind' | String | Zone files directory | -| `manala_bind_zones` | [] | Array | List of zone files | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example @@ -166,13 +131,16 @@ manala_bind_zones: ```yaml - hosts: servers - roles: - - { role: manala.bind } + tasks: + - import_role: + name: manala.roles.bind ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/bind/defaults/main.yml b/roles/bind/defaults/main.yml index 744e697ed..898658efd 100644 --- a/roles/bind/defaults/main.yml +++ b/roles/bind/defaults/main.yml @@ -10,6 +10,7 @@ manala_bind_user: bind manala_bind_group: bind # Options +manala_bind_options_file: /etc/default/{{ (ansible_distribution_release in ['stretch', 'buster'])|ternary('bind9','named') }} manala_bind_options: - -u {{ manala_bind_user }} diff --git a/roles/bind/filter_plugins/.gitignore b/roles/bind/filter_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/bind/filter_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/bind/filter_plugins/manala_bind.py b/roles/bind/filter_plugins/manala_bind.py deleted file mode 100644 index 47c02c87c..000000000 --- a/roles/bind/filter_plugins/manala_bind.py +++ /dev/null @@ -1,8 +0,0 @@ -class FilterModule(object): - def filters(self): - return { - 'manala_bind_zone_file': self.manala_bind_zone_file - } - - def manala_bind_zone_file(self, value): - return 'db.' + value.replace('.in-addr.arpa', '') diff --git a/roles/bind/meta/main.yml b/roles/bind/meta/main.yml index 1dcc9da27..51e99537f 100644 --- a/roles/bind/meta/main.yml +++ b/roles/bind/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: bind - author: Manala - company: Manala - description: Handle bind - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: bind + author: Manala + company: Manala + description: Handle bind + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - bind diff --git a/roles/bind/tasks/configs.yml b/roles/bind/tasks/configs.yml index f5247fdc7..c473e7055 100644 --- a/roles/bind/tasks/configs.yml +++ b/roles/bind/tasks/configs.yml @@ -7,10 +7,11 @@ owner: root group: "{{ manala_bind_group }}" mode: "0644" - with_items: "{{ manala_bind_configs }}" - when: (item.template is defined) - and (item.state|default('present') == 'present') - and (not item.omit|default(False)) + loop: "{{ manala_bind_configs }}" + when: + - item.template is defined + - item.state|default('present') == 'present' + - not item.omit|default(False) register: __manala_bind_configs_templates - name: configs > Contents @@ -20,17 +21,19 @@ owner: root group: "{{ manala_bind_group }}" mode: "0644" - with_items: "{{ manala_bind_configs }}" - when: (item.content is defined) - and (item.state|default('present') == 'present') - and (not item.omit|default(False)) + loop: "{{ manala_bind_configs }}" + when: + - item.content is defined + - item.state|default('present') == 'present' + - not item.omit|default(False) register: __manala_bind_configs_contents - name: configs > Absents file: path: "{{ manala_bind_configs_dir }}/{{ item.file }}" state: absent - with_items: "{{ manala_bind_configs }}" - when: (item.state|default('present') == 'absent') - and (not item.omit|default(False)) + loop: "{{ manala_bind_configs }}" + when: + - item.state|default('present') == 'absent' + - not item.omit|default(False) register: __manala_bind_configs_absents diff --git a/roles/bind/tasks/install.yml b/roles/bind/tasks/install.yml index 4d5b1f0dd..b929aa5d7 100644 --- a/roles/bind/tasks/install.yml +++ b/roles/bind/tasks/install.yml @@ -2,10 +2,15 @@ - name: install > Packages apt: - name: "{{ - manala_bind_install_packages|default(manala_bind_install_packages_default, True) - + (ansible_python.version.major == 2) | ternary(['python-dnspython'], ['python3-dnspython']) - }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ + manala_bind_install_packages|default(manala_bind_install_packages_default, True) + + (ansible_python.version.major == 2)|ternary( + ['python-dnspython'], + ['python3-dnspython'] + ) + }}" diff --git a/roles/bind/tasks/logs.yml b/roles/bind/tasks/logs.yml index 20c0dcda9..8a7578e1c 100644 --- a/roles/bind/tasks/logs.yml +++ b/roles/bind/tasks/logs.yml @@ -6,3 +6,4 @@ state: directory owner: "{{ manala_bind_user }}" group: "{{ manala_bind_group }}" + mode: "0755" diff --git a/roles/bind/tasks/options.yml b/roles/bind/tasks/options.yml index 3e0e90eb2..f8eebbbf7 100644 --- a/roles/bind/tasks/options.yml +++ b/roles/bind/tasks/options.yml @@ -2,7 +2,7 @@ - name: options > Default lineinfile: - path: /etc/default/bind9 + path: "{{ manala_bind_options_file }}" regexp: '^OPTIONS=' line: OPTIONS="{{ manala_bind_options|join(' ') }}" register: __manala_bind_options diff --git a/roles/bind/tasks/services.yml b/roles/bind/tasks/services.yml index c8720ba37..cd405bfbd 100644 --- a/roles/bind/tasks/services.yml +++ b/roles/bind/tasks/services.yml @@ -17,5 +17,5 @@ ) else 'started' }}" - with_items: + loop: - bind9 diff --git a/roles/bind/tasks/zones.yml b/roles/bind/tasks/zones.yml index fefd56bc1..4467b8877 100644 --- a/roles/bind/tasks/zones.yml +++ b/roles/bind/tasks/zones.yml @@ -3,36 +3,39 @@ - name: zones > Templates template: src: "{{ item.template }}" - dest: "{{ manala_bind_zones_dir }}/{{ item.file|default(item.zone|manala_bind_zone_file) }}" + dest: "{{ manala_bind_zones_dir }}/{{ item.file|default(item.zone|manala.roles.bind_zone_file) }}" owner: "{{ manala_bind_user }}" group: "{{ manala_bind_group }}" mode: "0644" force: "{{ not item.dynamic|default(False) }}" - with_items: "{{ manala_bind_zones }}" - when: (item.template is defined) - and (item.state|default('present') == 'present') - and (not item.omit|default(False)) + loop: "{{ manala_bind_zones }}" + when: + - item.template is defined + - item.state|default('present') == 'present' + - not item.omit|default(False) register: __manala_bind_zones_templates - name: zones > Contents copy: content: "{{ item.content }}" - dest: "{{ manala_bind_zones_dir }}/{{ item.file|default(item.zone|manala_bind_zone_file) }}" + dest: "{{ manala_bind_zones_dir }}/{{ item.file|default(item.zone|manala.roles.bind_zone_file) }}" owner: "{{ manala_bind_user }}" group: "{{ manala_bind_group }}" mode: "0644" force: "{{ not item.dynamic|default(False) }}" - with_items: "{{ manala_bind_zones }}" - when: (item.content is defined) - and (item.state|default('present') == 'present') - and (not item.omit|default(False)) + loop: "{{ manala_bind_zones }}" + when: + - item.content is defined + - item.state|default('present') == 'present' + - not item.omit|default(False) register: __manala_bind_zones_contents - name: zones > Absents file: - path: "{{ manala_bind_zones_dir }}/{{ item.file|default(item.zone|manala_bind_zone_file) }}" + path: "{{ manala_bind_zones_dir }}/{{ item.file|default(item.zone|manala.roles.bind_zone_file) }}" state: absent - with_items: "{{ manala_bind_zones }}" - when: (item.state|default('present') == 'absent') - and (not item.omit|default(False)) + loop: "{{ manala_bind_zones }}" + when: + - item.state|default('present') == 'absent' + - not item.omit|default(False) register: __manala_bind_zones_absents diff --git a/roles/bind/tasks/zones_records.yml b/roles/bind/tasks/zones_records.yml index 146ed37d4..6c77b50a2 100644 --- a/roles/bind/tasks/zones_records.yml +++ b/roles/bind/tasks/zones_records.yml @@ -2,7 +2,7 @@ - name: zones_records > Records nsupdate: - server: localhost + server: 127.0.0.1 zone: "{{ item.0.zone }}" record: "{{ item.1.record }}" value: "{{ item.1.value|default(omit) }}" @@ -17,10 +17,12 @@ (item.0.records_default|default({})).ttl|default(omit) ) }}" - with_subelements: - - "{{ manala_bind_zones }}" - - records - - skip_missing: true - when: (item.0.dynamic|default(False)) - and (item.0.state|default('present') == 'present') - and (not item.0.omit|default(False)) + loop: "{{ + manala_bind_zones + | subelements('records', skip_missing=True) + }}" + + when: + - item.0.dynamic|default(False) + - item.0.state|default('present') == 'present' + - not item.0.omit|default(False) diff --git a/roles/bind/tests/.gitignore b/roles/bind/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/bind/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/bind/tests/0100_install.goss.yml b/roles/bind/tests/0100_install.goss.yml deleted file mode 100644 index e90eb90ff..000000000 --- a/roles/bind/tests/0100_install.goss.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- - -package: - bind9: - installed: true diff --git a/roles/bind/tests/0100_install.yml b/roles/bind/tests/0100_install.yml deleted file mode 100644 index 24293eeda..000000000 --- a/roles/bind/tests/0100_install.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - roles: - - manala.bind - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/bind/tests/0200_options.goss.yml b/roles/bind/tests/0200_options.goss.yml deleted file mode 100644 index 49b56bf2e..000000000 --- a/roles/bind/tests/0200_options.goss.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -file: - /etc/default/bind9: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - OPTIONS="-u bind -4" - -command: - ps aux: - exit-status: 0 - stdout: - - /usr/sbin/named -u bind -4 diff --git a/roles/bind/tests/0200_options.yml b/roles/bind/tests/0200_options.yml deleted file mode 100644 index 7a3bef756..000000000 --- a/roles/bind/tests/0200_options.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_bind_options: - - -u {{ manala_bind_user }} - - -4 # IPv4 only - roles: - - manala.bind - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/bind/tests/0300_logs.goss.yml b/roles/bind/tests/0300_logs.goss.yml deleted file mode 100644 index 04a63422d..000000000 --- a/roles/bind/tests/0300_logs.goss.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -file: - /var/log/bind: - exists: true - filetype: directory - owner: bind - group: bind - mode: "0755" diff --git a/roles/bind/tests/0300_logs.yml b/roles/bind/tests/0300_logs.yml deleted file mode 100644 index 24293eeda..000000000 --- a/roles/bind/tests/0300_logs.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - roles: - - manala.bind - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/bind/tests/0400_configs.goss.yml b/roles/bind/tests/0400_configs.goss.yml deleted file mode 100644 index f85c0f144..000000000 --- a/roles/bind/tests/0400_configs.goss.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -file: - /etc/bind/named.conf.foo: - exists: true - filetype: file - owner: root - group: bind - mode: "0644" - contains: - - // Foo - /etc/bind/named.conf.bar: - exists: true - filetype: file - owner: root - group: bind - mode: "0644" - contains: - - // Bar - /etc/bind/named.conf.baz: - exists: false - /etc/bind/named.conf.qux: - exists: false diff --git a/roles/bind/tests/0400_configs.yml b/roles/bind/tests/0400_configs.yml deleted file mode 100644 index b0726172d..000000000 --- a/roles/bind/tests/0400_configs.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_bind_configs: - - file: named.conf.foo - template: fixtures/configs/named.conf.foo.j2 - - file: named.conf.bar - content: | - // Bar - - file: named.conf.baz - state: absent - - file: named.conf.qux - content: | - // Qux - omit: true - pre_tasks: - - file: - path: "{{ manala_bind_configs_dir }}" - state: directory - - copy: - dest: "{{ manala_bind_configs_dir }}/named.conf.baz" - content: | - // Baz - roles: - - manala.bind - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/bind/tests/0500_zones.goss.yml b/roles/bind/tests/0500_zones.goss.yml deleted file mode 100644 index c9f3d8a7c..000000000 --- a/roles/bind/tests/0500_zones.goss.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- - -file: - /var/cache/bind/db.foo.com: - exists: true - filetype: file - owner: bind - group: bind - mode: "0644" - contains: - - // Foo - /var/cache/bind/db.bar.com: - exists: true - filetype: file - owner: bind - group: bind - mode: "0644" - contains: - - // Bar - /var/cache/bind/db.baz.com: - exists: false - /var/cache/bind/db.qux.com: - exists: false - /var/cache/bind/db.quux.com: - exists: true - filetype: file - owner: bind - group: bind - mode: "0644" - contains: - - // Quux - /var/cache/bind/db.corge.com: - exists: true - contains: - - // Corge diff --git a/roles/bind/tests/0500_zones.yml b/roles/bind/tests/0500_zones.yml deleted file mode 100644 index 5b05e4a31..000000000 --- a/roles/bind/tests/0500_zones.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_bind_zones: - - zone: foo.com - template: fixtures/zones/db.foo.com.j2 - - zone: bar.com - content: | - // Bar - - zone: baz.com - state: absent - - zone: qux.com - content: | - // Qux - omit: true - - zone: quux.com - content: | - // Quux - dynamic: true - - zone: corge.com - content: | - // Grault - dynamic: true - pre_tasks: - - file: - path: "{{ manala_bind_zones_dir }}" - state: directory - - copy: - dest: "{{ manala_bind_zones_dir }}/db.baz.com" - content: | - // Baz - - copy: - dest: "{{ manala_bind_zones_dir }}/db.corge.com" - content: | - // Corge - roles: - - manala.bind - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/bind/tests/0600_services.goss.yml b/roles/bind/tests/0600_services.goss.yml deleted file mode 100644 index 3c473ca6f..000000000 --- a/roles/bind/tests/0600_services.goss.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -service: - bind9: - enabled: true - running: true diff --git a/roles/bind/tests/0600_services.yml b/roles/bind/tests/0600_services.yml deleted file mode 100644 index 24293eeda..000000000 --- a/roles/bind/tests/0600_services.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - roles: - - manala.bind - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/bind/tests/0700_zones_records.yml b/roles/bind/tests/0700_zones_records.yml deleted file mode 100644 index fba4baa7b..000000000 --- a/roles/bind/tests/0700_zones_records.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_bind_configs: - - file: named.conf.local - content: | - zone "foo.local" { - type master; - file "{{ 'foo.local'|manala_bind_zone_file }}"; - allow-update { localhost; }; - }; - manala_bind_zones: - - zone: foo.local - dynamic: true - content: | - @ IN SOA ns.foo.local. contact.foo.local. ( - 1 ; serial - 604800 ; refresh (1 week) - 86400 ; retry (1 day) - 2419200 ; expire (4 weeks) - 86400 ; minimum (1 day) - ) - @ IN NS ns.foo.local. - ns IN A 172.16.1.1 - records: - - { record: bar, value: 172.16.1.123 } - roles: - - manala.bind - post_tasks: - - apt: - name: - - bind9-host - install_recommends: false - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/bind/tests/fixtures/configs/named.conf.foo.j2 b/roles/bind/tests/fixtures/configs/named.conf.foo.j2 deleted file mode 100644 index 421f5b9f9..000000000 --- a/roles/bind/tests/fixtures/configs/named.conf.foo.j2 +++ /dev/null @@ -1 +0,0 @@ -// Foo diff --git a/roles/bind/tests/fixtures/zones/db.foo.com.j2 b/roles/bind/tests/fixtures/zones/db.foo.com.j2 deleted file mode 100644 index 421f5b9f9..000000000 --- a/roles/bind/tests/fixtures/zones/db.foo.com.j2 +++ /dev/null @@ -1 +0,0 @@ -// Foo diff --git a/roles/cloud_init/.gitignore b/roles/cloud_init/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/cloud_init/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/cloud_init/.manala/make/Makefile b/roles/cloud_init/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/cloud_init/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/cloud_init/.manala/make/Makefile.docker b/roles/cloud_init/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/cloud_init/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/cloud_init/.manala/make/Makefile.host b/roles/cloud_init/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/cloud_init/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/cloud_init/.manala/make/Makefile.manala b/roles/cloud_init/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/cloud_init/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/cloud_init/.manala/make/Makefile.travis b/roles/cloud_init/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/cloud_init/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/cloud_init/.manala/make/gmsl/__gmsl b/roles/cloud_init/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/cloud_init/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/cloud_init/.manala/make/gmsl/gmsl b/roles/cloud_init/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/cloud_init/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/cloud_init/.travis.yml b/roles/cloud_init/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/cloud_init/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/cloud_init/CHANGELOG.md b/roles/cloud_init/CHANGELOG.md deleted file mode 100644 index 3ddce57cd..000000000 --- a/roles/cloud_init/CHANGELOG.md +++ /dev/null @@ -1,44 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.2] - 2020-08-28 -### Changed -- Explicit file permissions - -## [2.0.1] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.4] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.3] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.2] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.0] - 2017-05-30 -### Added -- Handle installation -- Handle configs diff --git a/roles/cloud_init/Makefile b/roles/cloud_init/Makefile deleted file mode 100644 index 08b10c84f..000000000 --- a/roles/cloud_init/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.cloud_init -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/cloud_init/README.md b/roles/cloud_init/README.md index 28a8b06d1..8937b69b3 100644 --- a/roles/cloud_init/README.md +++ b/roles/cloud_init/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Cloud_init [![Build Status](https://travis-ci.org/manala/ansible-role-cloud_init.svg?branch=master)](https://travis-ci.org/manala/ansible-role-cloud_init) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Cloud_init This role will deal with the configuration of [Cloud-init](https://cloud-init.io/). -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,52 +14,36 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.cloud_init -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.cloud_init -``` +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| -------------------------------------------- | ------------------------ | -------| -------------------------------------- | -| `manala_cloud_init_install_packages` | ~ | String | Dependency packages to install | -| `manala_cloud_init_install_packages_default` | ['cloud-init'] | String | Default dependency packages to install | -| `manala_cloud_init_configs_exclusive` | false | String | Configs exclusivity | -| `manala_cloud_init_configs_dir` | '/etc/cloud/cloud.cfg.d' | String | Configs directory path | -| `manala_cloud_init_configs_template` | 'configs/empty.j2' | Array | Configs template path | -| `manala_cloud_init_configs` | [] | Array | Configs collection | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example ```yaml manala_cloud_init_configs: - file: 99_hostname.cfg - config: - - fqdn: delicious.manala.io - - hostname: delicious + config: | + fqdn: foo.manala.io + hostname: foo ``` ## Example playbook ```yaml - hosts: all - roles: - - { role: manala.cloud_init } + tasks: + - import_role: + name: manala.roles.cloud_init ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/cloud_init/defaults/main.yml b/roles/cloud_init/defaults/main.yml index 5f8f53fc1..040b9eab9 100644 --- a/roles/cloud_init/defaults/main.yml +++ b/roles/cloud_init/defaults/main.yml @@ -8,5 +8,5 @@ manala_cloud_init_install_packages_default: # Configs manala_cloud_init_configs_exclusive: false manala_cloud_init_configs_dir: /etc/cloud/cloud.cfg.d -manala_cloud_init_configs_template: ~ +manala_cloud_init_configs_defaults: {} manala_cloud_init_configs: [] diff --git a/roles/cloud_init/meta/main.yml b/roles/cloud_init/meta/main.yml index 39cb25dc6..4873dbd13 100644 --- a/roles/cloud_init/meta/main.yml +++ b/roles/cloud_init/meta/main.yml @@ -4,18 +4,18 @@ dependencies: [] galaxy_info: - role_name: cloud_init - author: Manala - company: Manala - description: Configure cloud-init - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: cloud_init + author: Manala + company: Manala + description: Configure cloud-init + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system diff --git a/roles/cloud_init/tasks/configs.yml b/roles/cloud_init/tasks/configs.yml index 2a796436d..191fb8e2e 100644 --- a/roles/cloud_init/tasks/configs.yml +++ b/roles/cloud_init/tasks/configs.yml @@ -1,25 +1,39 @@ --- -- name: configs > Templates +- name: configs > Exclusive + find: + path: "{{ manala_cloud_init_configs_dir }}" + file_type: file + patterns: "*" + changed_when: false + register: __manala_cloud_init_configs_exclusive_find + when: manala_cloud_init_configs_exclusive + +- name: configs > Templates present template: - src: "{{ item.template|default(manala_cloud_init_configs_template|ternary(manala_cloud_init_configs_template, 'configs/empty.j2')) }}" - dest: "{{ manala_cloud_init_configs_dir }}/{{ item.file }}" + src: "{{ item.template }}" + dest: "{{ item.file }}" owner: root group: root mode: "0644" - with_items: "{{ manala_cloud_init_configs }}" - -- name: configs > Exclusive - find files - command: "find -type f -printf '%P\n'" - args: - chdir: "{{ manala_cloud_init_configs_dir }}" - changed_when: false - register: __manala_cloud_init_configs_find_output - when: manala_cloud_init_configs_exclusive + loop: "{{ query( + 'manala.roles.templates_exclusive', + manala_cloud_init_configs, + __manala_cloud_init_configs_exclusive_find.files|default([]), + manala_cloud_init_configs_dir, + manala_cloud_init_configs_defaults.template|default('configs/_default.j2', true), + wantstate='present' + ) }}" -- name: configs > Exclusive - remove files +- name: configs > Files absent file: - path: "{{ manala_cloud_init_configs_dir }}/{{ item }}" + path: "{{ item.file }}" state: absent - when: manala_cloud_init_configs_exclusive and (item not in manala_cloud_init_configs|map(attribute='file')) - with_items: "{{ __manala_cloud_init_configs_find_output.stdout_lines|default([]) }}" + loop: "{{ query( + 'manala.roles.templates_exclusive', + manala_cloud_init_configs, + __manala_cloud_init_configs_exclusive_find.files|default([]), + manala_cloud_init_configs_dir, + manala_cloud_init_configs_defaults.template|default('configs/_default.j2', true), + wantstate='absent' + ) }}" diff --git a/roles/cloud_init/tasks/install.yml b/roles/cloud_init/tasks/install.yml index fd0a8ce6e..bff194522 100644 --- a/roles/cloud_init/tasks/install.yml +++ b/roles/cloud_init/tasks/install.yml @@ -2,7 +2,9 @@ - name: install > Packages apt: - name: "{{ manala_cloud_init_install_packages|default(manala_cloud_init_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_cloud_init_install_packages|default(manala_cloud_init_install_packages_default, True) }}" diff --git a/roles/cloud_init/templates/configs/_default.j2 b/roles/cloud_init/templates/configs/_default.j2 new file mode 100644 index 000000000..98112f114 --- /dev/null +++ b/roles/cloud_init/templates/configs/_default.j2 @@ -0,0 +1,3 @@ +{%- set config = item.config|default('') -%} + +{{ config }} diff --git a/roles/cloud_init/templates/configs/_macros.j2 b/roles/cloud_init/templates/configs/_macros.j2 deleted file mode 100644 index a020427cb..000000000 --- a/roles/cloud_init/templates/configs/_macros.j2 +++ /dev/null @@ -1,62 +0,0 @@ -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }}{{ '\n' }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default|indent(indent, true) }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {%- if value is sequence and value is not string -%} - {{ key }}:{{ '\n' }}{{ config(value, [], indent + 4) }} - {%- else -%} - {{ _config_parameter_key(key)|indent(indent, true) }}: {{ _config_parameter_value(value) }} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - {{ key }} -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {%- if value is sameas none -%} - {%- elif value is sameas false -%} - off - {%- elif value is string -%} - {{ value }} - {%- elif value is number -%} - {{ value }} - {%- endif -%} -{%- endmacro -%} diff --git a/roles/cloud_init/templates/configs/empty.j2 b/roles/cloud_init/templates/configs/empty.j2 deleted file mode 100644 index d1820ffff..000000000 --- a/roles/cloud_init/templates/configs/empty.j2 +++ /dev/null @@ -1,5 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{% set config = item.config|default([]) -%} - -{{ macros.config(config) }} diff --git a/roles/cloud_init/tests/.gitignore b/roles/cloud_init/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/cloud_init/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/cloud_init/tests/0100_install.yml b/roles/cloud_init/tests/0100_install.yml deleted file mode 100644 index 8f3da9937..000000000 --- a/roles/cloud_init/tests/0100_install.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - roles: - - manala.cloud_init - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/cloud_init/tests/0200_configs.goss.yml b/roles/cloud_init/tests/0200_configs.goss.yml deleted file mode 100644 index d69327058..000000000 --- a/roles/cloud_init/tests/0200_configs.goss.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -file: - /etc/cloud/cloud.cfg.d/99_hostname.cfg: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "fqdn: foo.manala.io" - - "hostname: foo" diff --git a/roles/cloud_init/tests/0200_configs.yml b/roles/cloud_init/tests/0200_configs.yml deleted file mode 100644 index 7d268f4cd..000000000 --- a/roles/cloud_init/tests/0200_configs.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_cloud_init_configs: - - file: 99_hostname.cfg - config: - - fqdn: foo.manala.io - - hostname: foo - roles: - - manala.cloud_init - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/composer/.gitignore b/roles/composer/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/composer/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/composer/.manala/make/Makefile b/roles/composer/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/composer/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/composer/.manala/make/Makefile.docker b/roles/composer/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/composer/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/composer/.manala/make/Makefile.host b/roles/composer/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/composer/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/composer/.manala/make/Makefile.manala b/roles/composer/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/composer/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/composer/.manala/make/Makefile.travis b/roles/composer/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/composer/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/composer/.manala/make/gmsl/__gmsl b/roles/composer/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/composer/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/composer/.manala/make/gmsl/gmsl b/roles/composer/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/composer/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/composer/.travis.yml b/roles/composer/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/composer/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/composer/CHANGELOG.md b/roles/composer/CHANGELOG.md deleted file mode 100644 index bbe274709..000000000 --- a/roles/composer/CHANGELOG.md +++ /dev/null @@ -1,73 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.6] - 2021-04-02 -### Added -- Update flags - -## [2.0.5] - 2021-01-27 -### Fixed -- Fix task so it works with ansible check diff - -## [2.0.4] - 2021-01-26 -### Changed -- Handle versions (specific and major) -- Use dict based users auth config - -## [2.0.3] - 2020-08-28 -### Changed -- Explicit file permissions on installer - -## [2.0.2] - 2020-08-26 -### Changed -- Explicit file permissions - -## [2.0.1] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.7] - 2019-11-08 -### Fixed -- macros.j2 and test - -## [1.0.6] - 2019-10-29 -### Added -- Allow to specify version to install - -## [1.0.5] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.4] - 2018-10-31 -### Added -- Ensure unzip package is present - -## [1.0.3] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.2] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.0] - 2017-06-21 -### Added -- Handle installation -- Handle configs diff --git a/roles/composer/Makefile b/roles/composer/Makefile deleted file mode 100644 index a1d0f165a..000000000 --- a/roles/composer/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.composer -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/composer/README.md b/roles/composer/README.md index 88dc29c8b..3a9592ee8 100644 --- a/roles/composer/README.md +++ b/roles/composer/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Composer [![Build Status](https://travis-ci.org/manala/ansible-role-composer.svg?branch=master)](https://travis-ci.org/manala/ansible-role-composer) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Composer This role will deal with the setup of [Composer](https://getcomposer.org) -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,37 +14,11 @@ This role requires php-cli >=5.3.2. You can use [manala.php](https://github.com/ ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.composer -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.composer -``` - -## Role Handlers - -None. +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -### Definition - -| Name | Default | Type | Description | -| ------------------------------------------ | ------------------------------ | ------ | -------------------------------------- | -| `manala_composer_version` | ~ | String | Version to install, latest by default | -| `manala_composer_install_packages` | ~ | Array | Dependency packages to install | -| `manala_composer_install_packages_default` | ['openssl', 'ca-certificates'] | Array | Default dependency packages to install | -| `manala_composer_bin` | '/usr/local/bin/composer' | String | Binary path | -| `manala_composer_users_auth_template` | ~ | String | User auth template path | -| `manala_composer_users_auth` | [] | Array | User auth config | -| `manala_composer` | {} | Dict | Use for custom flags | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example @@ -95,29 +57,23 @@ manala_composer_users_auth: "password": "my-secret-password1" } } - } - - user: baz - config: - # Use dict's array syntax (deprecated) - - github-oauth: - - github.com: 9927d2878ffa105fc5236c762f2fd7zfd28b841d - - http-basic: - - repo.example1.org: - - username: my-username1 - - password: my-secret-password1 + } ``` ## Example playbook ```yaml - hosts: servers - roles: - - role: manala.composer + tasks: + - import_role: + name: manala.roles.composer ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/composer/filter_plugins/.gitignore b/roles/composer/filter_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/composer/filter_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/composer/filter_plugins/manala_json.py b/roles/composer/filter_plugins/manala_json.py deleted file mode 100644 index 684a446d1..000000000 --- a/roles/composer/filter_plugins/manala_json.py +++ /dev/null @@ -1,24 +0,0 @@ -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -from ansible.errors import AnsibleFilterError -from ansible.module_utils.six import iteritems, string_types -from ansible.plugins.filter.core import to_nice_json - -def json(parameters, exclude=[]): - if not isinstance(parameters, dict): - raise AnsibleFilterError('manala_json expects a dict but was given a %s' % type(parameters)) - [parameters.pop(key, None) for key in exclude] - result = to_nice_json(parameters) - return result - - -class FilterModule(object): - ''' Manala json jinja2 filters ''' - - def filters(self): - filters = { - 'manala_json': json, - } - - return filters diff --git a/roles/composer/meta/main.yml b/roles/composer/meta/main.yml index ceee45cb1..3b005877c 100644 --- a/roles/composer/meta/main.yml +++ b/roles/composer/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: composer - author: Manala - company: Manala - description: Handle composer - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: composer + author: Manala + company: Manala + description: Handle composer + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - development - composer diff --git a/roles/composer/tasks/install.yml b/roles/composer/tasks/install.yml index b0284b89e..ad66ae17a 100644 --- a/roles/composer/tasks/install.yml +++ b/roles/composer/tasks/install.yml @@ -2,10 +2,12 @@ - name: install > Packages apt: - name: "{{ manala_composer_install_packages|default(manala_composer_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_composer_install_packages|default(manala_composer_install_packages_default, True) }}" - name: install > Check command: > @@ -24,22 +26,22 @@ }}" dest: "{{ manala_composer_bin }}" owner: root - group: "{{ (ansible_distribution_release in ['jessie', 'stretch'])|ternary('staff', 'root') }}" + group: "{{ (ansible_distribution_release in ['stretch'])|ternary('staff', 'root') }}" mode: "0755" force: true when: (__manala_composer_bin_check_result.rc == 2) - or ( - manala_composer_version|string is match('^\\d+\\.\\d+\\.\\d+$') - and ( - manala_composer_version|string != __manala_composer_bin_check_result.stdout|regex_replace('(.*)(\\d+\\.\\d+\\.\\d+)(.*)', '\\2') - ) - ) - or ( - manala_composer_version|string is match('^\\d+$') - and ( - manala_composer_version|string != __manala_composer_bin_check_result.stdout|regex_replace('(.*)(\\d+)(\\.\\d+\\.\\d+.*)', '\\2') - ) - ) - or ( - __manala_composer['update'] - ) + or ( + manala_composer_version|string is match('^\\d+\\.\\d+\\.\\d+$') + and ( + manala_composer_version|string != __manala_composer_bin_check_result.stdout|regex_replace('(.*)(\\d+\\.\\d+\\.\\d+)(.*)', '\\2') + ) + ) + or ( + manala_composer_version|string is match('^\\d+$') + and ( + manala_composer_version|string != __manala_composer_bin_check_result.stdout|regex_replace('(.*)(\\d+)(\\.\\d+\\.\\d+.*)', '\\2') + ) + ) + or ( + __manala_composer['update'] + ) diff --git a/roles/composer/tasks/users_auth.yml b/roles/composer/tasks/users_auth.yml index dc7255cd7..23225bf83 100644 --- a/roles/composer/tasks/users_auth.yml +++ b/roles/composer/tasks/users_auth.yml @@ -6,7 +6,7 @@ state: directory owner: "{{ item.user }}" mode: "0755" - with_items: "{{ manala_composer_users_auth }}" + loop: "{{ manala_composer_users_auth }}" - name: users_auth > Template template: @@ -14,4 +14,4 @@ dest: "{{ item.home|default('/root' if item.user == 'root' else '/home/' ~ item.user) }}/.composer/auth.json" owner: "{{ item.user }}" mode: "0644" - with_items: "{{ manala_composer_users_auth }}" + loop: "{{ manala_composer_users_auth }}" diff --git a/roles/composer/templates/users/auth/_default.j2 b/roles/composer/templates/users/auth/_default.j2 index 2862b589f..f4551714b 100644 --- a/roles/composer/templates/users/auth/_default.j2 +++ b/roles/composer/templates/users/auth/_default.j2 @@ -1,16 +1,8 @@ -{% set config = item.config|default({}) -%} +{%- set config = item.config|default({}) -%} {%- if config is mapping -%} -{{ config | manala_json }} - -{%- elif config is iterable and config is not string -%} - -{#- Deprecated -#} -{%- import '_macros.j2' as macros with context -%} - -{ -{{ macros.config(config, [], 4) }}} +{{ config | manala.roles.json }} {%- else -%} diff --git a/roles/composer/templates/users/auth/_macros.j2 b/roles/composer/templates/users/auth/_macros.j2 deleted file mode 100644 index f12cc1d91..000000000 --- a/roles/composer/templates/users/auth/_macros.j2 +++ /dev/null @@ -1,67 +0,0 @@ -{#- Deprecated -#} - -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {%- set outer_loop = loop -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }}{% if not outer_loop.last %},{% endif %}{{ '\n' }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {%- if value is sequence and value is not string -%} - {{ ('"' ~ key ~ '"')|indent(indent, true) }}: {{ '{\n' }}{{ config(value, [], indent + 4) }}{{ '}'|indent(indent, true) }} - {%- else -%} - {{ _config_parameter_key(key)|indent(indent, true) }}: {{ _config_parameter_value(value) }} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - "{{ key }}" -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {%- if value is sameas none -%} - {%- elif value is sameas true -%} - true - {%- elif value is sameas false -%} - false - {%- elif value is string -%} - "{{ value }}" - {%- elif value is number -%} - {{ value }} - {%- endif -%} -{%- endmacro -%} diff --git a/roles/composer/tests/.gitignore b/roles/composer/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/composer/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/composer/tests/0000_default.goss.yml b/roles/composer/tests/0000_default.goss.yml deleted file mode 100644 index 4b909cef6..000000000 --- a/roles/composer/tests/0000_default.goss.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -package: - openssl: - installed: true - ca-certificates: - installed: true - -file: - /usr/local/bin/composer: - exists: true - filetype: file - owner: root -{{ if .Env.DISTRIBUTION_RELEASE | regexMatch "jessie|stretch" }} - group: staff -{{ else }} - group: root -{{ end }} - mode: "0755" - /tmp/installer: - exists: false - -command: - unzip -v: - exit-status: 0 - stdout: - - UnZip - composer --version: - exit-status: 0 - stdout: - - Composer version diff --git a/roles/composer/tests/0000_default.yml b/roles/composer/tests/0000_default.yml deleted file mode 100644 index 1e3dfa023..000000000 --- a/roles/composer/tests/0000_default.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - apt: - name: - - "{{ (ansible_distribution_release in ['jessie'])|ternary('php5-cli', 'php-cli') }}" - install_recommends: false - - - block: - - import_role: - name: manala.composer - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/composer/tests/0110_install_version.goss.yml b/roles/composer/tests/0110_install_version.goss.yml deleted file mode 100644 index 4d31a4e68..000000000 --- a/roles/composer/tests/0110_install_version.goss.yml +++ /dev/null @@ -1,106 +0,0 @@ ---- - -# Default -{{ if has "default" .Vars.tags }} -file: - /usr/local/bin/composer: - exists: true - filetype: file - owner: root -{{ if .Env.DISTRIBUTION_RELEASE | regexMatch "jessie|stretch" }} - group: staff -{{ else }} - group: root -{{ end }} - mode: "0755" - -command: - composer --version: - exit-status: 0 - stdout: - - Composer version 1.8.0 -{{ end }} - -# Update -{{ if has "update" .Vars.tags }} -file: - /usr/local/bin/composer: - exists: true - filetype: file - owner: root -{{ if .Env.DISTRIBUTION_RELEASE | regexMatch "jessie|stretch" }} - group: staff -{{ else }} - group: root -{{ end }} - mode: "0755" - -command: - composer --version: - exit-status: 0 - stdout: - - Composer version 1.10.15 -{{ end }} - -# Major -{{ if has "major" .Vars.tags }} -file: - /usr/local/bin/composer: - exists: true - filetype: file - owner: root -{{ if .Env.DISTRIBUTION_RELEASE | regexMatch "jessie|stretch" }} - group: staff -{{ else }} - group: root -{{ end }} - mode: "0755" - -command: - composer --version: - exit-status: 0 - stdout: - - Composer version 1 -{{ end }} - -# Major - Change -{{ if has "major_change" .Vars.tags }} -file: - /usr/local/bin/composer: - exists: true - filetype: file - owner: root -{{ if .Env.DISTRIBUTION_RELEASE | regexMatch "jessie|stretch" }} - group: staff -{{ else }} - group: root -{{ end }} - mode: "0755" - -command: - composer --version: - exit-status: 0 - stdout: - - Composer version 1 -{{ end }} - -# Major - No change -{{ if has "major_no_change" .Vars.tags }} -file: - /usr/local/bin/composer: - exists: true - filetype: file - owner: root -{{ if .Env.DISTRIBUTION_RELEASE | regexMatch "jessie|stretch" }} - group: staff -{{ else }} - group: root -{{ end }} - mode: "0755" - -command: - composer --version: - exit-status: 0 - stdout: - - Composer version 1.10.15 -{{ end }} diff --git a/roles/composer/tests/0110_install_version.yml b/roles/composer/tests/0110_install_version.yml deleted file mode 100644 index dee207383..000000000 --- a/roles/composer/tests/0110_install_version.yml +++ /dev/null @@ -1,101 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - tags: [always] - block: - - apt: - name: - - "{{ (ansible_distribution_release in ['jessie'])|ternary('php5-cli', 'php-cli') }}" - install_recommends: false - - - tags: [default] - block: - - file: - path: /usr/local/bin/composer - state: absent - - import_role: - name: manala.composer - tasks_from: install - vars: - manala_composer_version: 1.8.0 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [default]}" validate - - - tags: [update] - block: - - file: - path: /usr/local/bin/composer - state: absent - - import_role: - name: manala.composer - tasks_from: install - - import_role: - name: manala.composer - tasks_from: install - vars: - manala_composer_version: 1.10.15 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [update]}" validate - - - tags: [major] - block: - - file: - path: /usr/local/bin/composer - state: absent - - import_role: - name: manala.composer - tasks_from: install - vars: - manala_composer_version: 1 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [major]}" validate - - - tags: [major_change] - block: - - file: - path: /usr/local/bin/composer - state: absent - - import_role: - name: manala.composer - tasks_from: install - vars: - manala_composer_version: 2.0.3 - - import_role: - name: manala.composer - tasks_from: install - vars: - manala_composer_version: 1 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [major_change]}" validate - - - tags: [major_no_change] - block: - - file: - path: /usr/local/bin/composer - state: absent - - import_role: - name: manala.composer - tasks_from: install - vars: - manala_composer_version: 1.10.15 - - import_role: - name: manala.composer - tasks_from: install - vars: - manala_composer_version: 1 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [major_no_change]}" validate diff --git a/roles/composer/tests/0200_users_auth.yml b/roles/composer/tests/0200_users_auth.yml deleted file mode 100644 index e966c02c5..000000000 --- a/roles/composer/tests/0200_users_auth.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - apt: - name: - - "{{ (ansible_distribution_release in ['jessie'])|ternary('php5-cli', 'php-cli') }}" - install_recommends: false - - - block: - - import_role: - name: manala.composer - vars: - manala_composer_users_auth: - - user: root - config: - github-oauth: - github.com: 9927d2878ffa105fc5236c762f2fd7zfd28b841d - http-basic: - repo.example1.org: - username: my-username1 - password: my-secret-password1 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/cron/.gitignore b/roles/cron/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/cron/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/cron/.manala/make/Makefile b/roles/cron/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/cron/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/cron/.manala/make/Makefile.docker b/roles/cron/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/cron/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/cron/.manala/make/Makefile.host b/roles/cron/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/cron/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/cron/.manala/make/Makefile.manala b/roles/cron/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/cron/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/cron/.manala/make/Makefile.travis b/roles/cron/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/cron/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/cron/.manala/make/gmsl/__gmsl b/roles/cron/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/cron/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/cron/.manala/make/gmsl/gmsl b/roles/cron/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/cron/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/cron/.travis.yml b/roles/cron/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/cron/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/cron/CHANGELOG.md b/roles/cron/CHANGELOG.md deleted file mode 100644 index d34a81643..000000000 --- a/roles/cron/CHANGELOG.md +++ /dev/null @@ -1,71 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [3.0.1] - 2021-03-29 -### Added -- Default job users can now be defined using `manala_cron_files_defaults` - -## [3.0.0] - 2021-01-15 -### Changed -- Use unified exclusive template lookup -- Use template ansible module instead of cron ones -- Deprecate job `name` parameter -- Rename job `job` parameter into `command` - -### Removed -- Already deprecated dict's array based environment variable handling - -## [2.0.3] - 2020-07-09 -### Added -- Handle defaults parameters for files - -## [2.0.2] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.1] - 2019-11-29 -### Changed -- Update 'lookup' to use 'query' -- Minimum required version of ansible up to 2.5.0 - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.5] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.4] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.3] - 2018-10-12 -### Added -- Support environment variables as dict ("env") - -### Changed -- Deprecate legacy "environment" parameter - -## [1.0.2] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.0] - 2017-06-21 -### Added -- Handle installation -- Handle files -- Handle services diff --git a/roles/cron/Makefile b/roles/cron/Makefile deleted file mode 100644 index f96fdf2d3..000000000 --- a/roles/cron/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.cron -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/cron/README.md b/roles/cron/README.md index 5ffd79cdd..4d0f4b0a8 100644 --- a/roles/cron/README.md +++ b/roles/cron/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Cron [![Build Status](https://travis-ci.org/manala/ansible-role-cron.svg?branch=master)](https://travis-ci.org/manala/ansible-role-cron) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Cron This role will deal with the setup of __Cron__. -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,36 +14,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.cron -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.cron -``` - -## Role Handlers - -| Name | Type | Description | -| ------------- | ------- | -------------------- | -| `cron restart | Service | Restart cron service | +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| -------------------------------------- | ------------- | ------- | -------------------------------------- | -| `manala_cron_install_packages` | ~ | Array | Dependency packages to install | -| `manala_cron_install_packages_default` | ['cron'] | Array | Default dependency packages to install | -| `manala_cron_files_exclusive` | false | Boolean | Files exclusivity | -| `manala_cron_files_dir` | '/etc/cron.d' | String | Files dir path | -| `manala_cron_files_defaults` | {} | Array | Defaults cron files parameters | -| `manala_cron_files` | [] | Array | Cron files collection | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example @@ -80,11 +43,6 @@ manala_cron_files: user: bar # Override default jobs user minute: 0 hour: 7 - # Deprecated - - name: foo-bar - job: php /srv/app/bin/console app:foo:bar - minute: 0 - hour: 7 # Template based - file: template template: my/cron.j2 @@ -106,13 +64,16 @@ manala_cron_files: ```yaml - hosts: servers - roles: - - role: manala.cron + tasks: + - import_role: + name: manala.roles.cron ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/cron/filter_plugins/.gitignore b/roles/cron/filter_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/cron/filter_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/cron/filter_plugins/manala_environment.py b/roles/cron/filter_plugins/manala_environment.py deleted file mode 100644 index 57a6e4b8d..000000000 --- a/roles/cron/filter_plugins/manala_environment.py +++ /dev/null @@ -1,53 +0,0 @@ -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -from ansible.errors import AnsibleFilterError -from ansible.module_utils.six import iteritems, string_types - -from numbers import Number - - -def environment(parameters, exclude=[]): - if not isinstance(parameters, dict): - raise AnsibleFilterError('manala_environment expects a dict but was given a %s' % type(parameters)) - [parameters.pop(key, None) for key in exclude] - result = '' - for key in sorted(parameters): - parameter = environment_parameter(parameters, key) - if parameter: - result += '\n%s' % parameter - return result.lstrip() - -def environment_parameter(parameters, key, required=False, default=None, comment=False): - if not isinstance(parameters, dict): - raise AnsibleFilterError('manala_environment_parameter parameters expects a dict but was given a %s' % type(parameters)) - if not isinstance(key, string_types): - raise AnsibleFilterError('manala_environment_parameter key expects a string but was given a %s' % type(key)) - if required and key not in parameters: - raise AnsibleFilterError('manala_environment_parameter requires a value for key %s' % key) - result = '' - value = parameters.get(key, default) - if isinstance(value, string_types): - result = '%s="%s"' % (key, value) - elif isinstance(value, Number): - result = '%s=%s' % (key, value) - else: - AnsibleFilterError('manala_environment_parameter value of an unknown type %s' % type(value)) - if key not in parameters: - if comment is True: - result = '#' + result.replace('\n', '\n#') - elif isinstance(comment, string_types): - result = comment - return result - - -class FilterModule(object): - ''' Manala environment jinja2 filters ''' - - def filters(self): - filters = { - 'manala_environment': environment, - 'manala_environment_parameter': environment_parameter, - } - - return filters diff --git a/roles/cron/handlers/main.yml b/roles/cron/handlers/main.yml index 557d5886d..7d7ccab69 100644 --- a/roles/cron/handlers/main.yml +++ b/roles/cron/handlers/main.yml @@ -2,5 +2,7 @@ - name: cron restart service: - name: cron + name: "{{ item }}" state: restarted + loop: + - cron diff --git a/roles/cron/lookup_plugins/.gitignore b/roles/cron/lookup_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/cron/lookup_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/cron/lookup_plugins/manala_templates_exclusive.py b/roles/cron/lookup_plugins/manala_templates_exclusive.py deleted file mode 100644 index ff57727f0..000000000 --- a/roles/cron/lookup_plugins/manala_templates_exclusive.py +++ /dev/null @@ -1,103 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.errors import AnsibleError -from ansible.module_utils._text import to_text - -import os - - -class LookupModule(LookupBase): - - def _recursive_flatten(self, terms): - if not isinstance(terms, list): - raise AnsibleError('Expect a list but was a %s' % type(terms)) - ret = [] - for term in terms: - if isinstance(term, (list, tuple)): - ret.extend( - self._recursive_flatten(term) - ) - else: - ret.append(term) - return ret - - def run(self, terms, variables=None, **kwargs): - - results = [] - - wantstate = kwargs.pop('wantstate', None) - - if wantstate and wantstate not in ['present', 'absent']: - raise AnsibleError('Expect a wanstate of "present" or "absent" but was "%s"' % to_text(wantstate)) - - templates = self._recursive_flatten(terms[0]) - exclusives = self._flatten(terms[1]) - dir = terms[2] - template = terms[3] - - itemDefault = { - 'state': 'present', - 'template': template - } - - # Mark exclusive templates as absent - for template in exclusives: - item = itemDefault.copy() - item.update({ - 'file': template['path'], - 'state': 'absent' - }) - results.append(item) - - for template in templates: - - items = [] - - # Must be a dict - if not isinstance(template, dict): - raise AnsibleError('Expect a dict but was a %s' % type(template)) - - # Check file key - if 'file' not in template: - # File name based on template - if 'template' in template: - template['file'] = os.path.splitext( - os.path.basename(template['template']) - )[0] - else: - raise AnsibleError('Expect a "file" key') - - item = itemDefault.copy() - item.update(template) - - if item['state'] not in ['present', 'absent', 'ignore']: - raise AnsibleError('Expect a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) - - if item['state'] == 'ignore': - continue - - item.update({ - 'file': os.path.join(dir, item['file']) - }) - - items.append(item) - - # Merge by file key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['file'] == item['file']: - results[i] = item - itemFound = True - break - - if not itemFound: - results.append(item) - - # Filter by state - if wantstate: - results = [result for result in results if result.get('state') == wantstate] - - return results diff --git a/roles/cron/meta/main.yml b/roles/cron/meta/main.yml index cd10fc440..c7c164e2f 100644 --- a/roles/cron/meta/main.yml +++ b/roles/cron/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: cron - author: Manala - company: Manala - description: Handle cron - license: MIT - min_ansible_version: 2.5.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: cron + author: Manala + company: Manala + description: Handle cron + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - cron diff --git a/roles/cron/tasks/files.yml b/roles/cron/tasks/files.yml index ad1693c81..267ebfb09 100644 --- a/roles/cron/tasks/files.yml +++ b/roles/cron/tasks/files.yml @@ -3,6 +3,7 @@ - name: files > Exclusive find: path: "{{ manala_cron_files_dir }}" + file_type: file patterns: "*" changed_when: false register: __manala_cron_files_exclusive_find @@ -16,14 +17,13 @@ group: root mode: "0644" loop: "{{ query( - 'manala_templates_exclusive', - manala_cron_files, - __manala_cron_files_exclusive_find.files|default([]), - manala_cron_files_dir, - manala_cron_files_defaults.template|default('files/_default.j2', true), - wantstate='present' - ) - }}" + 'manala.roles.templates_exclusive', + manala_cron_files, + __manala_cron_files_exclusive_find.files|default([]), + manala_cron_files_dir, + manala_cron_files_defaults.template|default('files/_default.j2', true), + wantstate='present' + ) }}" notify: - cron restart @@ -32,13 +32,12 @@ path: "{{ item.file }}" state: absent loop: "{{ query( - 'manala_templates_exclusive', - manala_cron_files, - __manala_cron_files_exclusive_find.files|default([]), - manala_cron_files_dir, - manala_cron_files_defaults.template|default('files/_default.j2', true), - wantstate='absent' - ) - }}" + 'manala.roles.templates_exclusive', + manala_cron_files, + __manala_cron_files_exclusive_find.files|default([]), + manala_cron_files_dir, + manala_cron_files_defaults.template|default('files/_default.j2', true), + wantstate='absent' + ) }}" notify: - cron restart diff --git a/roles/cron/tasks/install.yml b/roles/cron/tasks/install.yml index 0d5e9afb6..9aaab3ef0 100644 --- a/roles/cron/tasks/install.yml +++ b/roles/cron/tasks/install.yml @@ -2,7 +2,9 @@ - name: install > Packages apt: - name: "{{ manala_cron_install_packages|default(manala_cron_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_cron_install_packages|default(manala_cron_install_packages_default, True) }}" diff --git a/roles/cron/tasks/services.yml b/roles/cron/tasks/services.yml index 83b67c64b..def8dacef 100644 --- a/roles/cron/tasks/services.yml +++ b/roles/cron/tasks/services.yml @@ -4,5 +4,5 @@ service: name: "{{ item }}" state: started - with_items: + loop: - cron diff --git a/roles/cron/templates/files/_default.j2 b/roles/cron/templates/files/_default.j2 index 106eb60f6..fe8ce3da7 100644 --- a/roles/cron/templates/files/_default.j2 +++ b/roles/cron/templates/files/_default.j2 @@ -2,7 +2,7 @@ {{ item.config }} {% else %} {% if 'env' in item %} -{{ item.env|manala_environment }} +{{ item.env|manala.roles.environment }} {% endif %} {% for job in item.jobs|default([]) %} {% if job.state|default('present') == 'present' %} @@ -25,12 +25,7 @@ ) ) ) - }} - {#- Deprecated #} - {%- if 'job' in job %} {{ job.job }} - {%- else %} {{ job.command|mandatory }} - {%- endif %} - + }} {{ job.command|mandatory }} {% endif %} {% endfor %} {% endif %} diff --git a/roles/cron/tests/.gitignore b/roles/cron/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/cron/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/cron/tests/0000_default.yml b/roles/cron/tests/0000_default.yml deleted file mode 100644 index c810aff95..000000000 --- a/roles/cron/tests/0000_default.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_role: - name: manala.cron - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/cron/tests/0200_files.goss.yml b/roles/cron/tests/0200_files.goss.yml deleted file mode 100644 index 7fad0db4d..000000000 --- a/roles/cron/tests/0200_files.goss.yml +++ /dev/null @@ -1,134 +0,0 @@ ---- - -# Default -{{ if has "default" .Vars.tags }} -file: - tmp/files/default/default: - exists: true - mode: "0644" - owner: root - group: root - filetype: file - contains: - - 'FOO="bar"' - - "0 7 * * * bar cd /srv/app && bin/console app:bar:bar" - - "1 2 3 4 5 foo cd /srv/app && bin/console app:baz:baz" - - "* * * * * foo cd /srv/app && bin/console app:foo:present" - - "!* * * * * foo cd /srv/app && bin/console app:foo:absent" - - "0 7 * * * foo cd /srv/app && bin/console app:foo:foo" - tmp/files/default/default_content: - exists: true - mode: "0644" - owner: root - group: root - filetype: file - contains: - - "0 7 * * * root cd /srv/app && bin/console app:bar:bar" - tmp/files/default/template: - exists: true - mode: "0644" - owner: root - group: root - filetype: file - contains: - - Files foo - tmp/files/default/default_user: - exists: true - mode: "0644" - owner: root - group: root - filetype: file - contains: - - "* * * * * foo foo" - tmp/files/default/default_user_file: - exists: true - mode: "0644" - owner: root - group: root - filetype: file - contains: - - "* * * * * bar bar" - tmp/files/default/default_user_job: - exists: true - mode: "0644" - owner: root - group: root - filetype: file - contains: - - "* * * * * baz baz" -{{ end }} - -# State -{{ if has "state" .Vars.tags }} -file: - tmp/files/state/foo: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - size: 1 - tmp/files/state/bar: - exists: false - tmp/files/state/baz: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - size: 1 - tmp/files/state/qux: - exists: true - filetype: file - tmp/files/state/quux: - exists: false -{{ end }} - -# Defaults -{{ if has "defaults" .Vars.tags }} -file: - tmp/files/defaults/foo: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Files foo" - tmp/files/defaults/bar: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Files bar" - tmp/files/defaults/baz: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Files bar" -{{ end }} - -# Exclusive -{{ if has "exclusive" .Vars.tags }} -file: - tmp/files/exclusive/foo: - exists: false - tmp/files/exclusive/bar: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - size: 1 - tmp/files/exclusive/baz: - exists: false - tmp/files/exclusive/qux: - exists: false - tmp/files/exclusive/quux: - exists: false -{{ end }} diff --git a/roles/cron/tests/0200_files.yml b/roles/cron/tests/0200_files.yml deleted file mode 100644 index 7c12634ff..000000000 --- a/roles/cron/tests/0200_files.yml +++ /dev/null @@ -1,164 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - # Default - - tags: [default] - block: - - file: - path: tmp/files/default - state: "{{ item }}" - loop: [absent, directory] - - import_role: - # Play role fully on first run, so that handlers don't breaks - name: manala.cron - vars: - manala_cron_files_dir: tmp/files/default - manala_cron_files: - # Default - - file: default - user: foo - env: - FOO: bar - jobs: - - command: cd /srv/app && bin/console app:bar:bar - user: bar - minute: 0 - hour: 7 - - command: cd /srv/app && bin/console app:baz:baz - minute: 1 - hour: 2 - day: 3 - month: 4 - weekday: 5 - - command: cd /srv/app && bin/console app:foo:present - state: present - - command: cd /srv/app && bin/console app:foo:absent - state: absent - # Deprecated - - name: foo-foo - job: cd /srv/app && bin/console app:foo:foo - minute: 0 - hour: 7 - - file: default_content - config: | - 0 7 * * * root cd /srv/app && bin/console app:bar:bar - # Flatten - - - # Template - - file: template - template: files/foo.j2 - - import_role: - name: manala.cron - tasks_from: files - vars: - manala_cron_files_dir: tmp/files/default - manala_cron_files_defaults: - user: foo - manala_cron_files: - # Default - - file: default_user - jobs: - - command: foo - # Default - File - - file: default_user_file - user: bar - jobs: - - command: bar - # Default - Job - - file: default_user_job - user: bar - jobs: - - command: baz - user: baz - - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [default]}" validate - - # State - - tags: [state] - block: - - file: - path: tmp/files/state - state: "{{ item }}" - loop: [absent, directory] - - file: - path: tmp/files/state/{{ item }} - state: touch - loop: [bar, qux] - - import_role: - name: manala.cron - tasks_from: files - vars: - manala_cron_files_dir: tmp/files/state - manala_cron_files: - - file: foo - - file: bar - state: absent - - file: baz - state: present - - file: qux - state: ignore - - file: quux - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [state]}" validate - - # Defaults - - tags: [defaults] - block: - - file: - path: tmp/files/defaults - state: "{{ item }}" - loop: [absent, directory] - - import_role: - name: manala.cron - tasks_from: files - vars: - manala_cron_files_dir: tmp/files/defaults - manala_cron_files_defaults: - template: files/foo.j2 - manala_cron_files: - - file: foo - - template: files/bar.j2 - - file: baz - template: files/bar.j2 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [defaults]}" validate - - # Exclusive - - tags: [exclusive] - block: - - file: - path: tmp/files/exclusive - state: "{{ item }}" - loop: [absent, directory] - - file: - path: tmp/files/exclusive/{{ item }} - state: touch - loop: [foo, bar, baz, qux] - - import_role: - name: manala.cron - tasks_from: files - vars: - manala_cron_files_dir: tmp/files/exclusive - manala_cron_files_exclusive: true - manala_cron_files: - - file: bar - - file: qux - state: ignore - - file: quux - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [exclusive]}" validate diff --git a/roles/cron/tests/templates/files/bar.j2 b/roles/cron/tests/templates/files/bar.j2 deleted file mode 100644 index 00c5b5af4..000000000 --- a/roles/cron/tests/templates/files/bar.j2 +++ /dev/null @@ -1 +0,0 @@ -Files bar diff --git a/roles/cron/tests/templates/files/foo.j2 b/roles/cron/tests/templates/files/foo.j2 deleted file mode 100644 index 7345f5547..000000000 --- a/roles/cron/tests/templates/files/foo.j2 +++ /dev/null @@ -1 +0,0 @@ -Files foo diff --git a/roles/cron/tests/tmp/.gitignore b/roles/cron/tests/tmp/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/roles/cron/tests/tmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/roles/deploy/.gitignore b/roles/deploy/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/deploy/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/deploy/.manala/make/Makefile b/roles/deploy/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/deploy/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/deploy/.manala/make/Makefile.docker b/roles/deploy/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/deploy/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/deploy/.manala/make/Makefile.host b/roles/deploy/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/deploy/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/deploy/.manala/make/Makefile.manala b/roles/deploy/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/deploy/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/deploy/.manala/make/Makefile.travis b/roles/deploy/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/deploy/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/deploy/.manala/make/gmsl/__gmsl b/roles/deploy/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/deploy/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/deploy/.manala/make/gmsl/gmsl b/roles/deploy/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/deploy/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/deploy/.travis.yml b/roles/deploy/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/deploy/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/deploy/CHANGELOG.md b/roles/deploy/CHANGELOG.md deleted file mode 100644 index b5efd76ec..000000000 --- a/roles/deploy/CHANGELOG.md +++ /dev/null @@ -1,70 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.2] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.1] - 2019-11-29 -### Changed -- Update 'lookup' to use 'query' -- Minimum required version of ansible up to 2.5.0 - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.9] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.8] - 2019-04-16 -### Added -- Include strategy - -## [1.0.7] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.6] - 2018-06-05 -### Added -- Handle role inclusion - -### Changed -- Pass apt module packages list directly to the `name` option -- Replace deprecated uses of "include" - -## [1.0.5] - 2017-12-20 -### Fixed -- Install composer from https - -## [1.0.4] - 2017-12-14 -### Fixed -- Only tries to touch non existing shared files - -## [1.0.3] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.2] - 2017-10-30 -### Changed -- Fix ansible 2.3 warnings "when statements should not include jinja2 templating delimiters" - -## [1.0.1] - 2017-05-18 -### Added -- Unarchive strategy - -## [1.0.0] - 2017-05-16 -### Added -- Handle setup -- Handle strategies -- Handle unfinished deployments -- Handle shared paths -- Handle copied paths -- Handle writable dirs -- Handle tasks and posts tasks diff --git a/roles/deploy/Makefile b/roles/deploy/Makefile deleted file mode 100644 index 20f11d56e..000000000 --- a/roles/deploy/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.deploy -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/deploy/README.md b/roles/deploy/README.md index 9f17a8781..c7ad3d901 100644 --- a/roles/deploy/README.md +++ b/roles/deploy/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Deploy [![Build Status](https://travis-ci.org/manala/ansible-role-deploy.svg?branch=master)](https://travis-ci.org/manala/ansible-role-deploy) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Deploy This role will deal with __Deployment__. -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,25 +14,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.deploy -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.deploy -``` +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default| Type | Description | -|----------------------------- |------- |------ |------------- | -| | | | | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Strategies @@ -127,13 +101,16 @@ manala_deploy_tasks: ```yaml - hosts: servers - roles: - - { role: manala.deploy } + tasks: + - import_role: + name: manala.roles.deploy ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/deploy/callback_plugins/.gitignore b/roles/deploy/callback_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/deploy/callback_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/deploy/callback_plugins/manala_deploy_log.py b/roles/deploy/callback_plugins/manala_deploy_log.py deleted file mode 100644 index d8e691101..000000000 --- a/roles/deploy/callback_plugins/manala_deploy_log.py +++ /dev/null @@ -1,37 +0,0 @@ -from ansible.plugins.callback import CallbackBase - -class CallbackModule(CallbackBase): - CALLBACK_VERSION = 2.0 - CALLBACK_TYPE = 'notification' - CALLBACK_NAME = 'manala_deploy_log' - CALLBACK_NEEDS_WHITELIST = False - - def v2_runner_item_on_failed(self, result): - if ('module_stdout' in result._result) and result._result.get('module_stdout'): - print('module_stdout:') - print(result._result.get('module_stdout')) - if ('module_stderr' in result._result) and result._result.get('module_stderr'): - print('module_stderr:') - print(result._result.get('module_stderr')) - if ('stdout' in result._result) and result._result.get('stdout'): - print('stdout:') - print(result._result.get('stdout')) - if ('stderr' in result._result) and result._result.get('stderr'): - print('stderr:') - print(result._result.get('stderr')) - - def v2_runner_on_failed(self, result, ignore_errors=False): - if ('stdout' in result._result) and result._result.get('stdout'): - print('stdout:') - print(result._result.get('stdout')) - if ('stderr' in result._result) and result._result.get('stderr'): - print('stderr:') - print(result._result.get('stderr')) - - def v2_runner_on_ok(self, result): - if ('stdout' in result._result) and result._result.get('stdout'): - print('stdout:') - print(result._result.get('stdout')) - if ('stderr' in result._result) and result._result.get('stderr'): - print('stderr:') - print(result._result.get('stderr')) diff --git a/roles/deploy/defaults/main.yml b/roles/deploy/defaults/main.yml index 0170e5764..aaa7b5c75 100644 --- a/roles/deploy/defaults/main.yml +++ b/roles/deploy/defaults/main.yml @@ -1,10 +1,10 @@ --- # Dirs -manala_deploy_dir: ~ -manala_deploy_current_dir: current +manala_deploy_dir: ~ +manala_deploy_current_dir: current manala_deploy_releases_dir: releases -manala_deploy_shared_dir: shared +manala_deploy_shared_dir: shared # Releases manala_deploy_releases: 5 @@ -13,7 +13,7 @@ manala_deploy_releases: 5 manala_deploy_strategy: git # Strategy - Git -manala_deploy_strategy_git_repo: ~ +manala_deploy_strategy_git_repo: ~ manala_deploy_strategy_git_version: master # [READ-ONLY] This variable will be filled with the head commit hash @@ -33,7 +33,7 @@ manala_deploy_strategy_include_options: [] # Shared manala_deploy_shared_files: [] -manala_deploy_shared_dirs: [] +manala_deploy_shared_dirs: [] # Copied manala_deploy_copied: [] @@ -42,12 +42,12 @@ manala_deploy_copied: [] manala_deploy_removed: [] # Writable -manala_deploy_writable_dirs_default: # Ensure backward compatibility - mode: "{{ manala_deploy_writable_dirs_mode|default('ug=rwx,o=rx') }}" - follow: true +manala_deploy_writable_dirs_default: # Ensure backward compatibility + mode: "{{ manala_deploy_writable_dirs_mode|default('ug=rwx,o=rx') }}" + follow: true recurse: true manala_deploy_writable_dirs: [] # Tasks -manala_deploy_tasks: [] +manala_deploy_tasks: [] manala_deploy_post_tasks: [] diff --git a/roles/deploy/lookup_plugins/.gitignore b/roles/deploy/lookup_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/deploy/lookup_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/deploy/lookup_plugins/manala_deploy_tasks.py b/roles/deploy/lookup_plugins/manala_deploy_tasks.py deleted file mode 100644 index 0459808ab..000000000 --- a/roles/deploy/lookup_plugins/manala_deploy_tasks.py +++ /dev/null @@ -1,59 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.module_utils.six import string_types -from ansible.errors import AnsibleError - -class LookupModule(LookupBase): - - def run(self, terms, variables=None, **kwargs): - - results = [] - - itemDefault = { - 'options': None, - 'when': True, - 'dir': - (variables['deploy_helper']['new_release_path']) - if 'deploy_helper' in variables else - (variables['manala_deploy_dir'] + '/' + variables['manala_deploy_current_dir']), - 'shared_dir': - (variables['deploy_helper']['shared_path']) - if 'deploy_helper' in variables else - (variables['manala_deploy_dir'] + '/' + variables['manala_deploy_shared_dir']) - } - - for term in self._flatten(terms): - - items = [] - - # Task as a single line - if isinstance(term, string_types): - item = itemDefault.copy() - item.update({ - 'task': term - }) - items.append(item) - else: - # Guess task (first one not in blacklist) - item = None - for termKey, termValue in term.items(): - if termKey not in ['when']: - item = itemDefault.copy() - item.update({ - 'task': termKey, - 'options': termValue - }) - break - if item: - item.update({ - 'when': term.get('when') if 'when' in term else True - }) - items.append(item) - - # Merge - for item in items: - results.append(item) - - return results diff --git a/roles/deploy/lookup_plugins/manala_deploy_writable_dirs.py b/roles/deploy/lookup_plugins/manala_deploy_writable_dirs.py deleted file mode 100644 index 43e738dba..000000000 --- a/roles/deploy/lookup_plugins/manala_deploy_writable_dirs.py +++ /dev/null @@ -1,53 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.module_utils.six import string_types -from ansible.errors import AnsibleError - -class LookupModule(LookupBase): - - def run(self, terms, variables=None, **kwargs): - - results = [] - - dirs = self._flatten(terms[0]) - default = terms[1] - - for dir in dirs: - - items = [] - - # Dir as a single line - if isinstance(dir, string_types): - item = default.copy() - item.update({ - 'dir': dir - }) - items.append(item) - else: - - # Must be a dict - if not isinstance(dir, dict): - raise AnsibleError('Expect a dict') - - # Check index key - if 'dir' not in dir: - raise AnsibleError('Expect "dir" key') - - item = default.copy() - item.update(dir) - items.append(item) - - # Merge by index key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['dir'] == item['dir']: - results[i] = item - itemFound = True - break - if not itemFound: - results.append(item) - - return results diff --git a/roles/deploy/meta/main.yml b/roles/deploy/meta/main.yml index 13b5e982e..7c3d73600 100644 --- a/roles/deploy/meta/main.yml +++ b/roles/deploy/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: deploy - author: Manala - company: Manala - description: Handle deploy - license: MIT - min_ansible_version: 2.5.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: deploy + author: Manala + company: Manala + description: Handle deploy + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - development - deploy diff --git a/roles/deploy/tasks/clean.yml b/roles/deploy/tasks/clean.yml index 16feb4710..314d70ddf 100644 --- a/roles/deploy/tasks/clean.yml +++ b/roles/deploy/tasks/clean.yml @@ -2,10 +2,10 @@ - name: clean > Remove failed and old releases, keeping "{{ manala_deploy_releases }}" releases deploy_helper: - path: "{{ manala_deploy_dir }}" - current_path: "{{ manala_deploy_current_dir }}" + path: "{{ manala_deploy_dir }}" + current_path: "{{ manala_deploy_current_dir }}" releases_path: "{{ manala_deploy_releases_dir }}" - release: "{{ deploy_helper.new_release }}" + release: "{{ deploy_helper.new_release }}" keep_releases: "{{ manala_deploy_releases }}" - state: clean - ignore_errors: true + state: clean + failed_when: false diff --git a/roles/deploy/tasks/copied.yml b/roles/deploy/tasks/copied.yml index 30cb9ee80..6959dfab9 100644 --- a/roles/deploy/tasks/copied.yml +++ b/roles/deploy/tasks/copied.yml @@ -4,13 +4,15 @@ stat: path: "{{ deploy_helper.previous_release_path ~ '/' ~ item }}" register: __manala_deploy_copied_stats_output - with_items: "{{ manala_deploy_copied }}" + loop: "{{ manala_deploy_copied }}" - name: copied > Copy command: > cp -R - {{ deploy_helper.previous_release_path ~ '/' ~ item.1 ~ (__manala_deploy_copied_stats_output.results[item.0].stat.isdir|ternary('/', '')) }} - {{ deploy_helper.new_release_path ~ '/' ~ item.1 }} + {{ deploy_helper.previous_release_path ~ '/' ~ item ~ (__manala_deploy_copied_stats_output.results[index].stat.isdir|ternary('/', '')) }} + {{ deploy_helper.new_release_path ~ '/' ~ item }} delegate_to: "{{ inventory_hostname }}" - with_indexed_items: "{{ manala_deploy_copied }}" - when: __manala_deploy_copied_stats_output.results[item.0].stat.exists + loop: "{{ manala_deploy_copied | flatten }}" + loop_control: + index_var: index + when: __manala_deploy_copied_stats_output.results[index].stat.exists diff --git a/roles/deploy/tasks/finalize.yml b/roles/deploy/tasks/finalize.yml index 28fa7d203..c17094b87 100644 --- a/roles/deploy/tasks/finalize.yml +++ b/roles/deploy/tasks/finalize.yml @@ -2,10 +2,10 @@ - name: finalize > Remove the unfinished file and create a symlink to the newly deployed release deploy_helper: - path: "{{ manala_deploy_dir }}" - current_path: "{{ manala_deploy_current_dir }}" + path: "{{ manala_deploy_dir }}" + current_path: "{{ manala_deploy_current_dir }}" releases_path: "{{ manala_deploy_releases_dir }}" - release: "{{ deploy_helper.new_release }}" + release: "{{ deploy_helper.new_release }}" keep_releases: "{{ manala_deploy_releases }}" - state: finalize - clean: false + state: finalize + clean: false diff --git a/roles/deploy/tasks/removed.yml b/roles/deploy/tasks/removed.yml index fb80b4a3e..cfb263fe1 100644 --- a/roles/deploy/tasks/removed.yml +++ b/roles/deploy/tasks/removed.yml @@ -2,6 +2,6 @@ - name: removed > Files file: - path: "{{ deploy_helper.new_release_path ~ '/' ~ item }}" + path: "{{ deploy_helper.new_release_path ~ '/' ~ item }}" state: absent - with_items: "{{ manala_deploy_removed }}" + loop: "{{ manala_deploy_removed }}" diff --git a/roles/deploy/tasks/setup.yml b/roles/deploy/tasks/setup.yml index f28373adf..9fa5f78be 100644 --- a/roles/deploy/tasks/setup.yml +++ b/roles/deploy/tasks/setup.yml @@ -2,9 +2,9 @@ - name: setup > Create structure deploy_helper: - path: "{{ manala_deploy_dir }}" - current_path: "{{ manala_deploy_current_dir }}" + path: "{{ manala_deploy_dir }}" + current_path: "{{ manala_deploy_current_dir }}" releases_path: "{{ manala_deploy_releases_dir }}" - shared_path: "{{ manala_deploy_shared_dir }}" + shared_path: "{{ manala_deploy_shared_dir }}" keep_releases: "{{ manala_deploy_releases }}" - state: present + state: present diff --git a/roles/deploy/tasks/shared.yml b/roles/deploy/tasks/shared.yml index 61d6c45d8..7b5e3257c 100644 --- a/roles/deploy/tasks/shared.yml +++ b/roles/deploy/tasks/shared.yml @@ -2,40 +2,44 @@ - name: shared > Ensure release targets are absent file: - path: "{{ deploy_helper.new_release_path ~ '/' ~ item }}" + path: "{{ deploy_helper.new_release_path ~ '/' ~ item }}" state: absent - with_items: "{{ manala_deploy_shared_files + manala_deploy_shared_dirs }}" + loop: "{{ manala_deploy_shared_files + manala_deploy_shared_dirs }}" - name: shared > Stat shared files stat: path: "{{ deploy_helper.shared_path ~ '/' ~ item }}" register: __manala_deploy_shared_files_stats_output - with_items: "{{ manala_deploy_shared_files }}" + loop: "{{ manala_deploy_shared_files }}" -- name: shared > Ensure shared directories files are present +- name: shared > Ensure shared directories files are present # noqa risky-file-permissions file: - path: "{{ (deploy_helper.shared_path ~ '/' ~ item.1)|dirname }}" + path: "{{ (deploy_helper.shared_path ~ '/' ~ item)|dirname }}" state: directory - with_indexed_items: "{{ manala_deploy_shared_files }}" - when: not __manala_deploy_shared_files_stats_output.results[item.0].stat.exists + loop: "{{ manala_deploy_shared_files | flatten }}" + loop_control: + index_var: index + when: not __manala_deploy_shared_files_stats_output.results[index].stat.exists -- name: shared > Ensure shared files are present +- name: shared > Ensure shared files are present # noqa risky-file-permissions file: - path: "{{ deploy_helper.shared_path ~ '/' ~ item.1 }}" + path: "{{ deploy_helper.shared_path ~ '/' ~ item }}" state: touch - with_indexed_items: "{{ manala_deploy_shared_files }}" - when: not __manala_deploy_shared_files_stats_output.results[item.0].stat.exists + loop: "{{ manala_deploy_shared_files | flatten }}" + loop_control: + index_var: index + when: not __manala_deploy_shared_files_stats_output.results[index].stat.exists -- name: shared > Ensure shared dirs are present +- name: shared > Ensure shared dirs are present # noqa risky-file-permissions file: - path: "{{ deploy_helper.shared_path ~ '/' ~ item }}" + path: "{{ deploy_helper.shared_path ~ '/' ~ item }}" state: directory follow: true - with_items: "{{ manala_deploy_shared_dirs }}" + loop: "{{ manala_deploy_shared_dirs }}" - name: shared > Links file: - path: "{{ deploy_helper.new_release_path ~ '/' ~ item }}" - src: "{{ (deploy_helper.shared_path ~ '/' ~ item)|relpath((deploy_helper.new_release_path ~ '/' ~ item)|dirname) }}" + path: "{{ deploy_helper.new_release_path ~ '/' ~ item }}" + src: "{{ (deploy_helper.shared_path ~ '/' ~ item)|relpath((deploy_helper.new_release_path ~ '/' ~ item)|dirname) }}" state: link - with_items: "{{ manala_deploy_shared_files + manala_deploy_shared_dirs }}" + loop: "{{ manala_deploy_shared_files + manala_deploy_shared_dirs }}" diff --git a/roles/deploy/tasks/strategy/git.yml b/roles/deploy/tasks/strategy/git.yml index a4a51fe6f..3b90a1433 100644 --- a/roles/deploy/tasks/strategy/git.yml +++ b/roles/deploy/tasks/strategy/git.yml @@ -7,14 +7,14 @@ - name: strategy/git > Cached repository git: - repo: "{{ manala_deploy_strategy_git_repo }}" - dest: "{{ deploy_helper.shared_path ~ '/cached-copy' }}" - version: "{{ manala_deploy_strategy_git_version }}" + repo: "{{ manala_deploy_strategy_git_repo }}" + dest: "{{ deploy_helper.shared_path ~ '/cached-copy' }}" + version: "{{ manala_deploy_strategy_git_version }}" accept_hostkey: true - update: true + update: true - - name: strategy/git > Get head - command: git rev-parse --short HEAD # noqa 303 + - name: strategy/git > Get head # noqa command-instead-of-module + command: git rev-parse --short HEAD args: chdir: "{{ deploy_helper.shared_path ~ '/cached-copy' }}" register: __manala_deploy_strategy_git_head_result @@ -23,7 +23,7 @@ set_fact: manala_deploy_strategy_git_head: "{{ __manala_deploy_strategy_git_head_result.stdout }}" - - name: strategy/git > Export repository - command: git checkout-index -f -a --prefix="{{ deploy_helper.new_release_path }}/" # noqa 303 + - name: strategy/git > Export repository # noqa command-instead-of-module + command: git checkout-index -f -a --prefix="{{ deploy_helper.new_release_path }}/" args: chdir: "{{ deploy_helper.shared_path ~ '/cached-copy' }}" diff --git a/roles/deploy/tasks/strategy/synchronize.yml b/roles/deploy/tasks/strategy/synchronize.yml index f128a10f1..cac602912 100644 --- a/roles/deploy/tasks/strategy/synchronize.yml +++ b/roles/deploy/tasks/strategy/synchronize.yml @@ -7,6 +7,6 @@ - name: strategy/synchronize > Synchronize synchronize: - src: "{{ manala_deploy_strategy_synchronize_src }}" + src: "{{ manala_deploy_strategy_synchronize_src }}" dest: "{{ deploy_helper.new_release_path }}/" rsync_opts: "{{ manala_deploy_strategy_synchronize_rsync_options }}" diff --git a/roles/deploy/tasks/strategy/unarchive.yml b/roles/deploy/tasks/strategy/unarchive.yml index dfba64922..cda489537 100644 --- a/roles/deploy/tasks/strategy/unarchive.yml +++ b/roles/deploy/tasks/strategy/unarchive.yml @@ -5,7 +5,7 @@ - manala_deploy block: - - name: strategy/unarchive > Create dir + - name: strategy/unarchive > Create dir # noqa risky-file-permissions file: path: "{{ deploy_helper.new_release_path }}/" state: directory diff --git a/roles/deploy/tasks/tasks.yml b/roles/deploy/tasks/tasks.yml index 659d90194..12d407786 100644 --- a/roles/deploy/tasks/tasks.yml +++ b/roles/deploy/tasks/tasks.yml @@ -4,8 +4,7 @@ - name: tasks include_tasks: tasks/{{ item.task }}.yml loop: "{{ query( - 'manala_deploy_tasks', - __manala_deploy_tasks - ) - }}" + 'manala.roles.deploy_tasks', + __manala_deploy_tasks + ) }}" when: item.when diff --git a/roles/deploy/tasks/tasks/install_composer.yml b/roles/deploy/tasks/tasks/install_composer.yml index a3a034a83..b2a302b49 100644 --- a/roles/deploy/tasks/tasks/install_composer.yml +++ b/roles/deploy/tasks/tasks/install_composer.yml @@ -12,7 +12,7 @@ - name: tasks/install_composer > Download installer get_url: - url: https://getcomposer.org/installer + url: https://getcomposer.org/installer dest: /tmp when: not __manala_deploy_composer_bin_stat_result.stat.exists @@ -22,7 +22,7 @@ - name: tasks/install_composer > Remove installer file: - path: /tmp/installer + path: /tmp/installer state: absent when: not __manala_deploy_composer_bin_stat_result.stat.exists diff --git a/roles/deploy/tasks/tasks/service_reload.yml b/roles/deploy/tasks/tasks/service_reload.yml index ccab6997c..3054f06a7 100644 --- a/roles/deploy/tasks/tasks/service_reload.yml +++ b/roles/deploy/tasks/tasks/service_reload.yml @@ -7,5 +7,5 @@ - name: tasks/service_reload > "{{ item.options }}" service: - name: "{{ item.options }}" + name: "{{ item.options }}" state: reloaded diff --git a/roles/deploy/tasks/tasks/service_restart.yml b/roles/deploy/tasks/tasks/service_restart.yml index f79d901da..00751fe09 100644 --- a/roles/deploy/tasks/tasks/service_restart.yml +++ b/roles/deploy/tasks/tasks/service_restart.yml @@ -7,5 +7,5 @@ - name: tasks/service_restart > "{{ item.options }}" service: - name: "{{ item.options }}" + name: "{{ item.options }}" state: restarted diff --git a/roles/deploy/tasks/tasks/symfony_assets_version.yml b/roles/deploy/tasks/tasks/symfony_assets_version.yml index f2bd08948..16e926e6d 100644 --- a/roles/deploy/tasks/tasks/symfony_assets_version.yml +++ b/roles/deploy/tasks/tasks/symfony_assets_version.yml @@ -18,4 +18,4 @@ dest: "{{ item.dir }}/app/config/parameters.yml" regexp: "^(\\s*)assets_version:" line: "\\1assets_version: {{ __manala_deploy_symfony_assets_version }}" - backrefs: yes + backrefs: true diff --git a/roles/deploy/tasks/tasks/symfony_assets_version_file.yml b/roles/deploy/tasks/tasks/symfony_assets_version_file.yml index 21ec98ae8..5c0c848e3 100644 --- a/roles/deploy/tasks/tasks/symfony_assets_version_file.yml +++ b/roles/deploy/tasks/tasks/symfony_assets_version_file.yml @@ -13,10 +13,10 @@ deploy_helper.new_release }}" - - name: tasks/symfony_assets_version_file > Generate assets_version.yml + - name: tasks/symfony_assets_version_file > Generate assets_version.yml # noqa risky-file-permissions copy: dest: "{{ item.dir }}/app/config/assets_version.yml" - force: yes + force: true content: | parameters: assets_version: {{ __manala_deploy_symfony_assets_version }} diff --git a/roles/deploy/tasks/unfinished.yml b/roles/deploy/tasks/unfinished.yml index e82ef1db8..8c136570c 100644 --- a/roles/deploy/tasks/unfinished.yml +++ b/roles/deploy/tasks/unfinished.yml @@ -1,6 +1,6 @@ --- -- name: unfinished > Add an unfinished file, to allow cleanup on successful finalize +- name: unfinished > Add an unfinished file, to allow cleanup on successful finalize # noqa risky-file-permissions file: - path: "{{ deploy_helper.new_release_path }}/{{ deploy_helper.unfinished_filename }}" + path: "{{ deploy_helper.new_release_path }}/{{ deploy_helper.unfinished_filename }}" state: touch diff --git a/roles/deploy/tasks/writable/dirs.yml b/roles/deploy/tasks/writable/dirs.yml index 952807e32..4e0a7b6ae 100644 --- a/roles/deploy/tasks/writable/dirs.yml +++ b/roles/deploy/tasks/writable/dirs.yml @@ -2,24 +2,22 @@ - name: writable/dirs > "{{ item.dir }}" file: - path: "{{ deploy_helper.new_release_path ~ '/' ~ item.dir }}" + path: "{{ deploy_helper.new_release_path ~ '/' ~ item.dir }}" recurse: "{{ item.recurse|default(omit) }}" - follow: "{{ item.follow|default(omit) }}" - mode: "{{ item.mode|default(omit) }}" - state: directory + follow: "{{ item.follow|default(omit) }}" + mode: "{{ item.mode|default(omit) }}" + state: directory loop: "{{ query( - 'manala_deploy_writable_dirs', - manala_deploy_writable_dirs, - manala_deploy_writable_dirs_default - ) - }}" + 'manala.roles.deploy_writable_dirs', + manala_deploy_writable_dirs, + manala_deploy_writable_dirs_default + ) }}" - name: writable/dirs > Raw "{{ item.dir }}" raw: "{{ item.raw|format(dir=deploy_helper.new_release_path ~ '/' ~ item.dir) }}" when: item.raw is defined loop: "{{ query( - 'manala_deploy_writable_dirs', - manala_deploy_writable_dirs, - manala_deploy_writable_dirs_default - ) - }}" + 'manala.roles.deploy_writable_dirs', + manala_deploy_writable_dirs, + manala_deploy_writable_dirs_default + ) }}" diff --git a/roles/deploy/tests/.gitignore b/roles/deploy/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/deploy/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/deploy/tests/0100_setup.goss.yml b/roles/deploy/tests/0100_setup.goss.yml deleted file mode 100644 index f63d6c89f..000000000 --- a/roles/deploy/tests/0100_setup.goss.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -file: - /tmp/app: - exists: true - filetype: directory - /tmp/app/releases: - exists: true - filetype: directory - /tmp/app/shared: - exists: true - filetype: directory diff --git a/roles/deploy/tests/0100_setup.yml b/roles/deploy/tests/0100_setup.yml deleted file mode 100644 index 4d12a8082..000000000 --- a/roles/deploy/tests/0100_setup.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_deploy_dir: /tmp/app - manala_deploy_strategy: synchronize - manala_deploy_strategy_synchronize_src: "{{ playbook_dir ~ '/fixtures/app/' }}" - pre_tasks: - - import_tasks: pre_tasks/ssh.yml - - import_tasks: pre_tasks/rsync.yml - roles: - - manala.deploy - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/deploy/tests/0200_strategy.synchronize.goss.yml b/roles/deploy/tests/0200_strategy.synchronize.goss.yml deleted file mode 100644 index bcfb80103..000000000 --- a/roles/deploy/tests/0200_strategy.synchronize.goss.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- - -file: - /tmp/app/current/file: - exists: true - filetype: file - /tmp/app/current/file_shared: - exists: true - filetype: file - - /tmp/app/current/dir: - exists: true - filetype: directory - /tmp/app/current/dir/dir: - exists: true - filetype: directory - /tmp/app/current/dir/dir_shared: - exists: true - filetype: directory - /tmp/app/current/dir/file: - exists: true - filetype: file - /tmp/app/current/dir/file_shared: - exists: true - filetype: file - - /tmp/app/current/dir_shared: - exists: true - filetype: directory - /tmp/app/current/dir_shared/file: - exists: true - filetype: file diff --git a/roles/deploy/tests/0200_strategy.synchronize.yml b/roles/deploy/tests/0200_strategy.synchronize.yml deleted file mode 100644 index 4d12a8082..000000000 --- a/roles/deploy/tests/0200_strategy.synchronize.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_deploy_dir: /tmp/app - manala_deploy_strategy: synchronize - manala_deploy_strategy_synchronize_src: "{{ playbook_dir ~ '/fixtures/app/' }}" - pre_tasks: - - import_tasks: pre_tasks/ssh.yml - - import_tasks: pre_tasks/rsync.yml - roles: - - manala.deploy - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/deploy/tests/0201_strategy.include.goss.yml b/roles/deploy/tests/0201_strategy.include.goss.yml deleted file mode 100644 index 630d43b4a..000000000 --- a/roles/deploy/tests/0201_strategy.include.goss.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -file: - /tmp/app/current/strategy_include.txt: - exists: true - filetype: file diff --git a/roles/deploy/tests/0201_strategy.include.yml b/roles/deploy/tests/0201_strategy.include.yml deleted file mode 100644 index 7411d4204..000000000 --- a/roles/deploy/tests/0201_strategy.include.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_deploy_dir: /tmp/app - manala_deploy_strategy: include - manala_deploy_strategy_include_name: "{{ playbook_dir ~ '/fixtures/strategy/include.yml' }}" - manala_deploy_strategy_include_options: - filename: strategy_include.txt - roles: - - manala.deploy - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/deploy/tests/0300_unfinished.goss.yml b/roles/deploy/tests/0300_unfinished.goss.yml deleted file mode 100644 index e0d4e97aa..000000000 --- a/roles/deploy/tests/0300_unfinished.goss.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -file: - /tmp/app: - exists: true - filetype: directory diff --git a/roles/deploy/tests/0300_unfinished.yml b/roles/deploy/tests/0300_unfinished.yml deleted file mode 100644 index 4d12a8082..000000000 --- a/roles/deploy/tests/0300_unfinished.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_deploy_dir: /tmp/app - manala_deploy_strategy: synchronize - manala_deploy_strategy_synchronize_src: "{{ playbook_dir ~ '/fixtures/app/' }}" - pre_tasks: - - import_tasks: pre_tasks/ssh.yml - - import_tasks: pre_tasks/rsync.yml - roles: - - manala.deploy - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/deploy/tests/0400_shared.goss.yml b/roles/deploy/tests/0400_shared.goss.yml deleted file mode 100644 index a67f4c477..000000000 --- a/roles/deploy/tests/0400_shared.goss.yml +++ /dev/null @@ -1,102 +0,0 @@ ---- - -file: - - /tmp/app/shared/file_shared: - exists: true - filetype: file - /tmp/app/shared/file_shared_existing: - exists: true - filetype: file - /tmp/app/shared/file_shared_existing_link: - exists: true - filetype: symlink - linked-to: /tmp/app/shared/file_shared_existing - /tmp/app/current/file_shared: - exists: true - filetype: symlink - linked-to: ../../shared/file_shared - /tmp/app/current/file_shared_existing: - exists: true - filetype: symlink - linked-to: ../../shared/file_shared_existing - /tmp/app/current/file_shared_existing_link: - exists: true - filetype: symlink - linked-to: ../../shared/file_shared_existing_link - - /tmp/app/shared/dir: - exists: true - filetype: directory - /tmp/app/shared/dir/file_shared: - exists: true - filetype: file - /tmp/app/shared/dir/file_shared_existing: - exists: true - filetype: file - /tmp/app/shared/dir/file_shared_existing_link: - exists: true - filetype: symlink - linked-to: /tmp/app/shared/dir/file_shared_existing - /tmp/app/current/dir/file_shared: - exists: true - filetype: symlink - linked-to: ../../../shared/dir/file_shared - /tmp/app/current/dir/file_shared_existing: - exists: true - filetype: symlink - linked-to: ../../../shared/dir/file_shared_existing - /tmp/app/current/dir/file_shared_existing_link: - exists: true - filetype: symlink - linked-to: ../../../shared/dir/file_shared_existing_link - - /tmp/app/shared/dir/dir: - exists: true - filetype: directory - /tmp/app/shared/dir/dir/file_shared: - exists: true - filetype: file - /tmp/app/shared/dir/dir/file_shared_existing: - exists: true - filetype: file - /tmp/app/shared/dir/dir/file_shared_existing_link: - exists: true - filetype: symlink - linked-to: /tmp/app/shared/dir/dir/file_shared_existing - /tmp/app/current/dir/dir/file_shared: - exists: true - filetype: symlink - linked-to: ../../../../shared/dir/dir/file_shared - /tmp/app/current/dir/dir/file_shared_existing: - exists: true - filetype: symlink - linked-to: ../../../../shared/dir/dir/file_shared_existing - /tmp/app/current/dir/dir/file_shared_existing_link: - exists: true - filetype: symlink - linked-to: ../../../../shared/dir/dir/file_shared_existing_link - - /tmp/app/shared/dir_shared: - exists: true - filetype: directory - /tmp/app/current/dir_shared: - exists: true - filetype: symlink - linked-to: ../../shared/dir_shared - - /tmp/app/shared/dir/dir_shared: - exists: true - filetype: directory - /tmp/app/current/dir/dir_shared: - exists: true - filetype: symlink - linked-to: ../../../shared/dir/dir_shared - - /tmp/app/shared/dir/dir/dir_shared: - exists: true - filetype: directory - /tmp/app/current/dir/dir/dir_shared: - exists: true - filetype: symlink - linked-to: ../../../../shared/dir/dir/dir_shared diff --git a/roles/deploy/tests/0400_shared.yml b/roles/deploy/tests/0400_shared.yml deleted file mode 100644 index 1ca735cc8..000000000 --- a/roles/deploy/tests/0400_shared.yml +++ /dev/null @@ -1,53 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_deploy_dir: /tmp/app - manala_deploy_strategy: synchronize - manala_deploy_strategy_synchronize_src: "{{ playbook_dir ~ '/fixtures/app/' }}" - manala_deploy_shared_files: - - file_shared - - file_shared_existing - - file_shared_existing_link - - dir/file_shared - - dir/file_shared_existing - - dir/file_shared_existing_link - - dir/dir/file_shared - - dir/dir/file_shared_existing - - dir/dir/file_shared_existing_link - manala_deploy_shared_dirs: - - dir_shared - - dir/dir_shared - - dir/dir/dir_shared - pre_tasks: - - import_tasks: pre_tasks/ssh.yml - - import_tasks: pre_tasks/rsync.yml - - file: - path: /tmp/app/{{ item }} - state: directory - with_items: - - shared - - shared/dir - - shared/dir/dir - - file: - path: /tmp/app/{{ item }} - state: touch - with_items: - - shared/file_shared_existing - - shared/dir/file_shared_existing - - shared/dir/dir/file_shared_existing - - file: - path: /tmp/app/{{ item }}_link - src: /tmp/app/{{ item }} - state: link - with_items: - - shared/file_shared_existing - - shared/dir/file_shared_existing - - shared/dir/dir/file_shared_existing - roles: - - manala.deploy - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/deploy/tests/0500_copied.goss.yml b/roles/deploy/tests/0500_copied.goss.yml deleted file mode 100644 index 8ff74ad1d..000000000 --- a/roles/deploy/tests/0500_copied.goss.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -file: - /tmp/app/current/vendor: - exists: true - filetype: directory diff --git a/roles/deploy/tests/0500_copied.yml b/roles/deploy/tests/0500_copied.yml deleted file mode 100644 index 6961cb040..000000000 --- a/roles/deploy/tests/0500_copied.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_deploy_dir: /tmp/app - manala_deploy_strategy: synchronize - manala_deploy_strategy_synchronize_src: "{{ playbook_dir ~ '/fixtures/app/' }}" - manala_deploy_copied: - - vendor - pre_tasks: - - import_tasks: pre_tasks/ssh.yml - - import_tasks: pre_tasks/rsync.yml - - import_tasks: pre_tasks/vendor.yml - roles: - - manala.deploy - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/deploy/tests/0600_writable.goss.yml b/roles/deploy/tests/0600_writable.goss.yml deleted file mode 100644 index bc7ad0b68..000000000 --- a/roles/deploy/tests/0600_writable.goss.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -file: - /tmp/app/current/dir: - exists: true - mode: "0777" - filetype: directory diff --git a/roles/deploy/tests/0600_writable.yml b/roles/deploy/tests/0600_writable.yml deleted file mode 100644 index 0f25219a4..000000000 --- a/roles/deploy/tests/0600_writable.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_deploy_dir: /tmp/app - manala_deploy_strategy: synchronize - manala_deploy_strategy_synchronize_src: "{{ playbook_dir ~ '/fixtures/app/' }}" - manala_deploy_writable_dirs_default: - mode: ugo=rwx - follow: true - recurse: true - manala_deploy_writable_dirs: - - dir - pre_tasks: - - import_tasks: pre_tasks/ssh.yml - - import_tasks: pre_tasks/rsync.yml - roles: - - manala.deploy - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/deploy/tests/0700_tasks.raw.goss.yml b/roles/deploy/tests/0700_tasks.raw.goss.yml deleted file mode 100644 index 678420a08..000000000 --- a/roles/deploy/tests/0700_tasks.raw.goss.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -file: - /tmp/manala_deploy_tasks.txt: - exists: true - filetype: file diff --git a/roles/deploy/tests/0700_tasks.raw.yml b/roles/deploy/tests/0700_tasks.raw.yml deleted file mode 100644 index d75638bb1..000000000 --- a/roles/deploy/tests/0700_tasks.raw.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_deploy_dir: /tmp/app - manala_deploy_strategy: synchronize - manala_deploy_strategy_synchronize_src: "{{ playbook_dir ~ '/fixtures/app/' }}" - manala_deploy_tasks: - - raw: touch /tmp/manala_deploy_tasks.txt - pre_tasks: - - import_tasks: pre_tasks/ssh.yml - - import_tasks: pre_tasks/rsync.yml - roles: - - manala.deploy - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/deploy/tests/0800_removed.goss.yml b/roles/deploy/tests/0800_removed.goss.yml deleted file mode 100644 index c6ee9b78c..000000000 --- a/roles/deploy/tests/0800_removed.goss.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- - -file: - - /tmp/app/current/file: - exists: false - /tmp/app/current/file_shared: - exists: true - filetype: file - - /tmp/app/current/dir: - exists: false - /tmp/app/current/dir_shared: - exists: true - filetype: directory diff --git a/roles/deploy/tests/0800_removed.yml b/roles/deploy/tests/0800_removed.yml deleted file mode 100644 index 9eea8372e..000000000 --- a/roles/deploy/tests/0800_removed.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_deploy_dir: /tmp/app - manala_deploy_strategy: synchronize - manala_deploy_strategy_synchronize_src: "{{ playbook_dir ~ '/fixtures/app/' }}" - manala_deploy_removed: - - file - - dir - pre_tasks: - - import_tasks: pre_tasks/ssh.yml - - import_tasks: pre_tasks/rsync.yml - roles: - - manala.deploy - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/deploy/tests/0900_finalize.goss.yml b/roles/deploy/tests/0900_finalize.goss.yml deleted file mode 100644 index c8a973150..000000000 --- a/roles/deploy/tests/0900_finalize.goss.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -file: - /tmp/app/current: - exists: true - filetype: symlink diff --git a/roles/deploy/tests/0900_finalize.yml b/roles/deploy/tests/0900_finalize.yml deleted file mode 100644 index 4d12a8082..000000000 --- a/roles/deploy/tests/0900_finalize.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_deploy_dir: /tmp/app - manala_deploy_strategy: synchronize - manala_deploy_strategy_synchronize_src: "{{ playbook_dir ~ '/fixtures/app/' }}" - pre_tasks: - - import_tasks: pre_tasks/ssh.yml - - import_tasks: pre_tasks/rsync.yml - roles: - - manala.deploy - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/deploy/tests/1000_clean.goss.yml b/roles/deploy/tests/1000_clean.goss.yml deleted file mode 100644 index 21028776a..000000000 --- a/roles/deploy/tests/1000_clean.goss.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -command: - find /tmp/app/releases -mindepth 1 -maxdepth 1 -type d | wc -l: - exit-status: 0 - stdout: - - 3 diff --git a/roles/deploy/tests/1000_clean.yml b/roles/deploy/tests/1000_clean.yml deleted file mode 100644 index 187237a47..000000000 --- a/roles/deploy/tests/1000_clean.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_deploy_dir: /tmp/app - manala_deploy_strategy: synchronize - manala_deploy_strategy_synchronize_src: "{{ playbook_dir ~ '/fixtures/app/' }}" - manala_deploy_releases: 2 - pre_tasks: - - import_tasks: pre_tasks/ssh.yml - - import_tasks: pre_tasks/rsync.yml - - import_tasks: pre_tasks/releases.yml - roles: - - manala.deploy - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/deploy/tests/1100_post_tasks.raw.goss.yml b/roles/deploy/tests/1100_post_tasks.raw.goss.yml deleted file mode 100644 index 35263160d..000000000 --- a/roles/deploy/tests/1100_post_tasks.raw.goss.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -file: - /tmp/manala_deploy_post_tasks.txt: - exists: true - filetype: file diff --git a/roles/deploy/tests/1100_post_tasks.raw.yml b/roles/deploy/tests/1100_post_tasks.raw.yml deleted file mode 100644 index 4f492865e..000000000 --- a/roles/deploy/tests/1100_post_tasks.raw.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_deploy_dir: /tmp/app - manala_deploy_strategy: synchronize - manala_deploy_strategy_synchronize_src: "{{ playbook_dir ~ '/fixtures/app/' }}" - manala_deploy_tasks: - - raw: touch /tmp/manala_deploy_post_tasks.txt - pre_tasks: - - import_tasks: pre_tasks/ssh.yml - - import_tasks: pre_tasks/rsync.yml - roles: - - manala.deploy - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/deploy/tests/fixtures/strategy/include.yml b/roles/deploy/tests/fixtures/strategy/include.yml deleted file mode 100644 index 21caa3622..000000000 --- a/roles/deploy/tests/fixtures/strategy/include.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- - -- name: strategy/include - block: - - name: strategy/s3 > Create release dir - file: - path: "{{ deploy_helper.new_release_path }}/" - state: directory - - - name: strategy/include > Touch file - file: - path: "{{ deploy_helper.new_release_path }}/{{ manala_deploy_strategy_include_options.filename }}" - state: touch diff --git a/roles/deploy/tests/pre_tasks/releases.yml b/roles/deploy/tests/pre_tasks/releases.yml deleted file mode 100644 index 370b26dd9..000000000 --- a/roles/deploy/tests/pre_tasks/releases.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- - -- file: - path: /tmp/app/releases/20170520092302 - state: directory - -- file: - path: /tmp/app/releases/20170520092413 - state: directory - -- file: - path: /tmp/app/releases/20170520092714 - state: directory - -- file: - path: /tmp/app/releases/20170520092738 - state: directory - -- file: - path: /tmp/app/releases/20170520093012 - state: directory - -- file: - path: /tmp/app/releases/20170520093234 - state: directory diff --git a/roles/deploy/tests/pre_tasks/rsync.yml b/roles/deploy/tests/pre_tasks/rsync.yml deleted file mode 100644 index e6e0dafdd..000000000 --- a/roles/deploy/tests/pre_tasks/rsync.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -- apt: - name: - - rsync - install_recommends: false diff --git a/roles/deploy/tests/pre_tasks/ssh.yml b/roles/deploy/tests/pre_tasks/ssh.yml deleted file mode 100644 index 52ac9e831..000000000 --- a/roles/deploy/tests/pre_tasks/ssh.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -- apt: - name: - - ssh - install_recommends: false diff --git a/roles/deploy/tests/pre_tasks/vendor.yml b/roles/deploy/tests/pre_tasks/vendor.yml deleted file mode 100644 index 1ea3faba5..000000000 --- a/roles/deploy/tests/pre_tasks/vendor.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- file: - path: /tmp/app/releases/20170520092302/vendor - state: directory - -- file: - path: /tmp/app/current - state: link - src: /tmp/app/releases/20170520092302 diff --git a/roles/dhcp/.gitignore b/roles/dhcp/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/dhcp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/dhcp/.manala/make/Makefile b/roles/dhcp/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/dhcp/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/dhcp/.manala/make/Makefile.docker b/roles/dhcp/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/dhcp/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/dhcp/.manala/make/Makefile.host b/roles/dhcp/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/dhcp/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/dhcp/.manala/make/Makefile.manala b/roles/dhcp/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/dhcp/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/dhcp/.manala/make/Makefile.travis b/roles/dhcp/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/dhcp/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/dhcp/.manala/make/gmsl/__gmsl b/roles/dhcp/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/dhcp/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/dhcp/.manala/make/gmsl/gmsl b/roles/dhcp/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/dhcp/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/dhcp/.travis.yml b/roles/dhcp/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/dhcp/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/dhcp/CHANGELOG.md b/roles/dhcp/CHANGELOG.md deleted file mode 100644 index 2db4937ad..000000000 --- a/roles/dhcp/CHANGELOG.md +++ /dev/null @@ -1,30 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [1.0.2] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [1.0.2] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.1] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.0] - 2018-03-15 -### Added -- Handle installation -- Handle interfaces -- Handle config -- Handle services diff --git a/roles/dhcp/Makefile b/roles/dhcp/Makefile deleted file mode 100644 index 0aaec84f4..000000000 --- a/roles/dhcp/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.dhcp -ROLE_DISTRIBUTIONS = debian.stretch debian.buster diff --git a/roles/dhcp/README.md b/roles/dhcp/README.md index 30f50c620..5929472f3 100644 --- a/roles/dhcp/README.md +++ b/roles/dhcp/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Dhcp [![Build Status](https://travis-ci.org/manala/ansible-role-dhcp.svg?branch=master)](https://travis-ci.org/manala/ansible-role-dhcp) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Dhcp This role will deal with the setup of [ISC DHCP Server](https://www.isc.org/downloads/dhcp/). -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,36 +14,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.dhcp -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.dhcp -``` - -## Role Handlers - -| Name | Type | Description | -| -------------- | ------- | -------------------- | -| `dhcp restart` | Service | Restart dhcp service | +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| -------------------------------------- | ---------------------- | ------ | -------------------------------------- | -| `manala_dhcp_install_packages` | ~ | Array | Dependency packages to install | -| `manala_dhcp_install_packages_default` | ['isc-dhcp-server'] | Array | Default dependency packages to install | -| `manala_dhcp_interfaces` | [] | Array | Network interfaces | -| `manala_dhcp_config_file` | '/etc/dhcp/dhcpd.conf' | String | Configuration destination path | -| `manala_dhcp_config_template` | ~ | String | Configuration template | -| `manala_dhcp_config_content` | ~ | String | Configuration content | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example @@ -84,13 +47,16 @@ manala_dhcp_config_content: | ```yaml - hosts: servers - roles: - - { role: manala.dhcp } + tasks: + - import_role: + name: manala.roles.dhcp ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/dhcp/defaults/main.yml b/roles/dhcp/defaults/main.yml index 5d1391990..4957c1a11 100644 --- a/roles/dhcp/defaults/main.yml +++ b/roles/dhcp/defaults/main.yml @@ -6,6 +6,7 @@ manala_dhcp_install_packages_default: - isc-dhcp-server # Interfaces +manala_dhcp_interfaces_file: /etc/default/isc-dhcp-server manala_dhcp_interfaces: [] # Config diff --git a/roles/dhcp/handlers/main.yml b/roles/dhcp/handlers/main.yml index b4804fd84..ad35d88e1 100644 --- a/roles/dhcp/handlers/main.yml +++ b/roles/dhcp/handlers/main.yml @@ -2,5 +2,7 @@ - name: dhcp restart service: - name: isc-dhcp-server + name: "{{ item }}" state: restarted + loop: + - isc-dhcp-server diff --git a/roles/dhcp/meta/main.yml b/roles/dhcp/meta/main.yml index 51ece957d..58f08b761 100644 --- a/roles/dhcp/meta/main.yml +++ b/roles/dhcp/meta/main.yml @@ -4,18 +4,19 @@ dependencies: [] galaxy_info: - role_name: dhcp - author: Manala - company: Manala - description: Handle isc dhcp server - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: dhcp + author: Manala + company: Manala + description: Handle isc dhcp server + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - stretch - buster + - bullseye galaxy_tags: - system - dhcp diff --git a/roles/dhcp/tasks/install.yml b/roles/dhcp/tasks/install.yml index 1fade2d61..a8cfd526f 100644 --- a/roles/dhcp/tasks/install.yml +++ b/roles/dhcp/tasks/install.yml @@ -2,7 +2,9 @@ - name: install > Packages apt: - name: "{{ manala_dhcp_install_packages|default(manala_dhcp_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_dhcp_install_packages|default(manala_dhcp_install_packages_default, True) }}" diff --git a/roles/dhcp/tasks/interfaces.yml b/roles/dhcp/tasks/interfaces.yml index 0ee37a50c..414e8cb1b 100644 --- a/roles/dhcp/tasks/interfaces.yml +++ b/roles/dhcp/tasks/interfaces.yml @@ -2,7 +2,7 @@ - name: interfaces > Default lineinfile: - path: /etc/default/isc-dhcp-server + path: "{{ manala_dhcp_interfaces_file }}" regexp: '^INTERFACESv4=' line: INTERFACESv4="{{ manala_dhcp_interfaces|join(' ') }}" notify: diff --git a/roles/dhcp/tasks/services.yml b/roles/dhcp/tasks/services.yml index e4394f246..658af28a2 100644 --- a/roles/dhcp/tasks/services.yml +++ b/roles/dhcp/tasks/services.yml @@ -4,5 +4,5 @@ service: name: "{{ item }}" state: started - with_items: + loop: - isc-dhcp-server diff --git a/roles/dhcp/tests/.gitignore b/roles/dhcp/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/dhcp/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/dhcp/tests/0100_install.goss.yml b/roles/dhcp/tests/0100_install.goss.yml deleted file mode 100644 index a94ce3058..000000000 --- a/roles/dhcp/tests/0100_install.goss.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- - -package: - isc-dhcp-server: - installed: true diff --git a/roles/dhcp/tests/0100_install.yml b/roles/dhcp/tests/0100_install.yml deleted file mode 100644 index a4d76c889..000000000 --- a/roles/dhcp/tests/0100_install.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - roles: - - manala.dhcp - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/dhcp/tests/0200_interfaces.goss.yml b/roles/dhcp/tests/0200_interfaces.goss.yml deleted file mode 100644 index b774baa66..000000000 --- a/roles/dhcp/tests/0200_interfaces.goss.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -file: - /etc/default/isc-dhcp-server: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - INTERFACESv4="eth0" - -command: - ps aux: - exit-status: 0 - stdout: - - /usr/sbin/dhcpd -4 -q -cf /etc/dhcp/dhcpd.conf eth0 diff --git a/roles/dhcp/tests/0200_interfaces.yml b/roles/dhcp/tests/0200_interfaces.yml deleted file mode 100644 index 170d687b7..000000000 --- a/roles/dhcp/tests/0200_interfaces.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_dhcp_interfaces: - - "{{ ansible_default_ipv4.interface }}" - manala_dhcp_config_content: | - subnet {{ ansible_default_ipv4.network }} netmask {{ ansible_default_ipv4.netmask }} { - } - roles: - - manala.dhcp - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/dhcp/tests/0300_config.goss.yml b/roles/dhcp/tests/0300_config.goss.yml deleted file mode 100644 index 0a5a8275b..000000000 --- a/roles/dhcp/tests/0300_config.goss.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- - -file: - /etc/dhcp/dhcpd.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "# Foo" diff --git a/roles/dhcp/tests/0300_config.yml b/roles/dhcp/tests/0300_config.yml deleted file mode 100644 index 24c745e36..000000000 --- a/roles/dhcp/tests/0300_config.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_dhcp_interfaces: - - "{{ ansible_default_ipv4.interface }}" - manala_dhcp_config_content: | - subnet {{ ansible_default_ipv4.network }} netmask {{ ansible_default_ipv4.netmask }} { - } - # Foo - roles: - - manala.dhcp - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/dhcp/tests/0400_services.goss.yml b/roles/dhcp/tests/0400_services.goss.yml deleted file mode 100644 index 55bbfe16e..000000000 --- a/roles/dhcp/tests/0400_services.goss.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -service: - isc-dhcp-server: - enabled: true - running: true diff --git a/roles/dhcp/tests/0400_services.yml b/roles/dhcp/tests/0400_services.yml deleted file mode 100644 index 170d687b7..000000000 --- a/roles/dhcp/tests/0400_services.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_dhcp_interfaces: - - "{{ ansible_default_ipv4.interface }}" - manala_dhcp_config_content: | - subnet {{ ansible_default_ipv4.network }} netmask {{ ansible_default_ipv4.netmask }} { - } - roles: - - manala.dhcp - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/dnsmasq/.gitignore b/roles/dnsmasq/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/dnsmasq/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/dnsmasq/.manala/make/Makefile b/roles/dnsmasq/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/dnsmasq/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/dnsmasq/.manala/make/Makefile.docker b/roles/dnsmasq/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/dnsmasq/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/dnsmasq/.manala/make/Makefile.host b/roles/dnsmasq/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/dnsmasq/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/dnsmasq/.manala/make/Makefile.manala b/roles/dnsmasq/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/dnsmasq/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/dnsmasq/.manala/make/Makefile.travis b/roles/dnsmasq/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/dnsmasq/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/dnsmasq/.manala/make/gmsl/__gmsl b/roles/dnsmasq/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/dnsmasq/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/dnsmasq/.manala/make/gmsl/gmsl b/roles/dnsmasq/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/dnsmasq/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/dnsmasq/.travis.yml b/roles/dnsmasq/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/dnsmasq/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/dnsmasq/CHANGELOG.md b/roles/dnsmasq/CHANGELOG.md deleted file mode 100644 index 565f990e6..000000000 --- a/roles/dnsmasq/CHANGELOG.md +++ /dev/null @@ -1,45 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.2] - 2020-08-28 -### Changed -- Explicit file permissions - -## [2.0.1] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.4] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.3] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.2] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.0] - 2017-06-14 -### Added -- Handle installation -- Handle configs -- Handle services diff --git a/roles/dnsmasq/Makefile b/roles/dnsmasq/Makefile deleted file mode 100644 index e3b74f9bb..000000000 --- a/roles/dnsmasq/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.dnsmasq -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/dnsmasq/README.md b/roles/dnsmasq/README.md index 5aab12d8b..be9a7050c 100644 --- a/roles/dnsmasq/README.md +++ b/roles/dnsmasq/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Dnsmasq [![Build Status](https://travis-ci.org/manala/ansible-role-dnsmasq.svg?branch=master)](https://travis-ci.org/manala/ansible-role-dnsmasq) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Dnsmasq This role will deal with the setup of [Dnsmasq](http://www.thekelleys.org.uk/dnsmasq/doc.html). -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,56 +14,34 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.dnsmasq -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.dnsmasq -``` - -## Role Handlers - -| Name | Type | Description | -| ----------------- | ------- | ----------------------- | -| `dnsmasq restart` | Service | Restart dnsmasq service | +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| ----------------------------------------- | ---------------- | ------- | -------------------------------------- | -| `manala_dnsmasq_install_packages` | ~ | Array | Dependency packages to install | -| `manala_dnsmasq_install_packages_default` | ['dnsmasq'] | Array | Default dependency packages to install | -| `manala_dnsmasq_configs_exclusive` | false | Boolean | Configurations exclusivity | -| `manala_dnsmasq_configs_dir` | '/etc/dnsmasq.d' | String | Configurations directory path | -| `manala_dnsmasq_configs_template` | ~ | String | Configurations template | -| `manala_dnsmasq_configs` | [] | Array | Configurations | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example ```yaml manala_dnsmasq_configs: - - file: dev.conf - template: configs/default.dev.j2 + - file: dev.conf + template: my/config.j2 ``` ## Example playbook ```yaml - hosts: servers - roles: - - { role: manala.dnsmasq } + tasks: + - import_role: + name: manala.roles.dnsmasq ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/dnsmasq/defaults/main.yml b/roles/dnsmasq/defaults/main.yml index d40fa0ee1..e7f8ed39f 100644 --- a/roles/dnsmasq/defaults/main.yml +++ b/roles/dnsmasq/defaults/main.yml @@ -8,5 +8,5 @@ manala_dnsmasq_install_packages_default: # Configs manala_dnsmasq_configs_exclusive: false manala_dnsmasq_configs_dir: /etc/dnsmasq.d -manala_dnsmasq_configs_template: ~ +manala_dnsmasq_configs_defaults: {} manala_dnsmasq_configs: [] diff --git a/roles/dnsmasq/handlers/main.yml b/roles/dnsmasq/handlers/main.yml index b6cf70ff3..3621fe082 100644 --- a/roles/dnsmasq/handlers/main.yml +++ b/roles/dnsmasq/handlers/main.yml @@ -2,5 +2,7 @@ - name: dnsmasq restart service: - name: dnsmasq + name: "{{ item }}" state: restarted + loop: + - dnsmasq diff --git a/roles/dnsmasq/meta/main.yml b/roles/dnsmasq/meta/main.yml index 71c48c09e..52d0306ad 100644 --- a/roles/dnsmasq/meta/main.yml +++ b/roles/dnsmasq/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: dnsmasq - author: Manala - company: Manala - description: Handle dnsmasq - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: dnsmasq + author: Manala + company: Manala + description: Handle dnsmasq + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - dnsmasq diff --git a/roles/dnsmasq/tasks/configs.yml b/roles/dnsmasq/tasks/configs.yml index f4a5ee4dd..12255bdaa 100644 --- a/roles/dnsmasq/tasks/configs.yml +++ b/roles/dnsmasq/tasks/configs.yml @@ -1,29 +1,43 @@ --- -- name: configs > Templates +- name: configs > Exclusive + find: + path: "{{ manala_dnsmasq_configs_dir }}" + file_type: file + patterns: "*" + changed_when: false + register: __manala_dnsmasq_configs_exclusive_find + when: manala_dnsmasq_configs_exclusive + +- name: configs > Templates present template: - src: "{{ item.template|default(manala_dnsmasq_configs_template|ternary(manala_dnsmasq_configs_template, 'configs/empty.j2')) }}" - dest: "{{ manala_dnsmasq_configs_dir }}/{{ item.file }}" + src: "{{ item.template }}" + dest: "{{ item.file }}" owner: root group: root mode: "0644" - with_items: "{{ manala_dnsmasq_configs }}" + loop: "{{ query( + 'manala.roles.templates_exclusive', + manala_dnsmasq_configs, + __manala_dnsmasq_configs_exclusive_find.files|default([]), + manala_dnsmasq_configs_dir, + manala_dnsmasq_configs_defaults.template|default('configs/_default.j2', true), + wantstate='present' + ) }}" notify: - dnsmasq restart -- name: configs > Exclusive - find files - command: "find -type f -printf '%P\n'" - args: - chdir: "{{ manala_dnsmasq_configs_dir }}" - changed_when: false - register: __manala_dnsmasq_configs_find_output - when: manala_dnsmasq_configs_exclusive - -- name: configs > Exclusive - remove files +- name: configs > Files absent file: - path: "{{ manala_dnsmasq_configs_dir }}/{{ item }}" + path: "{{ item.file }}" state: absent - when: manala_dnsmasq_configs_exclusive and (item not in manala_dnsmasq_configs|map(attribute='file')) - with_items: "{{ __manala_dnsmasq_configs_find_output.stdout_lines|default([]) }}" + loop: "{{ query( + 'manala.roles.templates_exclusive', + manala_dnsmasq_configs, + __manala_dnsmasq_configs_exclusive_find.files|default([]), + manala_dnsmasq_configs_dir, + manala_dnsmasq_configs_defaults.template|default('configs/_default.j2', true), + wantstate='absent' + ) }}" notify: - dnsmasq restart diff --git a/roles/dnsmasq/tasks/install.yml b/roles/dnsmasq/tasks/install.yml index f65fbb916..5faa66962 100644 --- a/roles/dnsmasq/tasks/install.yml +++ b/roles/dnsmasq/tasks/install.yml @@ -2,7 +2,9 @@ - name: install > Packages apt: - name: "{{ manala_dnsmasq_install_packages|default(manala_dnsmasq_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_dnsmasq_install_packages|default(manala_dnsmasq_install_packages_default, True) }}" diff --git a/roles/dnsmasq/tasks/services.yml b/roles/dnsmasq/tasks/services.yml index 052510ac3..6042e0358 100644 --- a/roles/dnsmasq/tasks/services.yml +++ b/roles/dnsmasq/tasks/services.yml @@ -4,5 +4,5 @@ service: name: "{{ item }}" state: started - with_items: + loop: - dnsmasq diff --git a/roles/dnsmasq/templates/configs/_default.j2 b/roles/dnsmasq/templates/configs/_default.j2 new file mode 100644 index 000000000..98112f114 --- /dev/null +++ b/roles/dnsmasq/templates/configs/_default.j2 @@ -0,0 +1,3 @@ +{%- set config = item.config|default('') -%} + +{{ config }} diff --git a/roles/dnsmasq/templates/configs/_macros.j2 b/roles/dnsmasq/templates/configs/_macros.j2 deleted file mode 100644 index e51515f1f..000000000 --- a/roles/dnsmasq/templates/configs/_macros.j2 +++ /dev/null @@ -1,62 +0,0 @@ -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }}{{ '\n' }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {%- if value is sequence and value is not string -%} - [{{ key }}]{{ '\n' }}{{ config(value, []) }} - {%- else -%} - {{ _config_parameter_key(key)|indent(indent, true) }}={{ _config_parameter_value(value) }} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - {{ key }} -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {%- if value is sameas none -%} - {%- elif value is sameas true -%} - true - {%- elif value is string -%} - {{ value }} - {%- elif value is number -%} - {{ value }} - {%- endif -%} -{%- endmacro -%} diff --git a/roles/dnsmasq/templates/configs/default.dev.j2 b/roles/dnsmasq/templates/configs/default.dev.j2 deleted file mode 100644 index 215e7b7cb..000000000 --- a/roles/dnsmasq/templates/configs/default.dev.j2 +++ /dev/null @@ -1,12 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{% set config = item.config|default([]) -%} - -{{ macros.config_row(config, 'user', 'root') }} -{{ macros.config_row(config, 'address', '/dev/127.0.0.1') }} -{{ macros.config_row(config, 'listen-address', '127.0.0.1') }} -{{ macros.config(config, [ - 'user', - 'address', - 'listen-address' -]) }} diff --git a/roles/dnsmasq/templates/configs/empty.j2 b/roles/dnsmasq/templates/configs/empty.j2 deleted file mode 100644 index 1aeec32c3..000000000 --- a/roles/dnsmasq/templates/configs/empty.j2 +++ /dev/null @@ -1,5 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{% set config = item.config|default({}) -%} - -{{ macros.config(config) }} diff --git a/roles/dnsmasq/tests/.gitignore b/roles/dnsmasq/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/dnsmasq/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/dnsmasq/tests/0100_install.goss.yml b/roles/dnsmasq/tests/0100_install.goss.yml deleted file mode 100644 index 4e59066dc..000000000 --- a/roles/dnsmasq/tests/0100_install.goss.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- - -package: - dnsmasq: - installed: true diff --git a/roles/dnsmasq/tests/0100_install.yml b/roles/dnsmasq/tests/0100_install.yml deleted file mode 100644 index b0f573b4b..000000000 --- a/roles/dnsmasq/tests/0100_install.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - roles: - - manala.dnsmasq - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/dnsmasq/tests/0200_configs.goss.yml b/roles/dnsmasq/tests/0200_configs.goss.yml deleted file mode 100644 index f9c68dcc8..000000000 --- a/roles/dnsmasq/tests/0200_configs.goss.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- - -file: - /etc/dnsmasq.d/foo: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - alias=11.22.33.44,55.66.77.88 diff --git a/roles/dnsmasq/tests/0200_configs.yml b/roles/dnsmasq/tests/0200_configs.yml deleted file mode 100644 index 22c9532a8..000000000 --- a/roles/dnsmasq/tests/0200_configs.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_dnsmasq_configs: - - file: foo - config: - - alias: 11.22.33.44,55.66.77.88 - roles: - - manala.dnsmasq - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/dnsmasq/tests/0300_services.goss.yml b/roles/dnsmasq/tests/0300_services.goss.yml deleted file mode 100644 index f7c8ee7a9..000000000 --- a/roles/dnsmasq/tests/0300_services.goss.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -service: - dnsmasq: - enabled: true - running: true diff --git a/roles/dnsmasq/tests/0300_services.yml b/roles/dnsmasq/tests/0300_services.yml deleted file mode 100644 index b0f573b4b..000000000 --- a/roles/dnsmasq/tests/0300_services.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - roles: - - manala.dnsmasq - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/docker/.gitignore b/roles/docker/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/docker/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/docker/.manala/make/Makefile b/roles/docker/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/docker/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/docker/.manala/make/Makefile.docker b/roles/docker/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/docker/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/docker/.manala/make/Makefile.host b/roles/docker/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/docker/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/docker/.manala/make/Makefile.manala b/roles/docker/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/docker/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/docker/.manala/make/Makefile.travis b/roles/docker/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/docker/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/docker/.manala/make/gmsl/__gmsl b/roles/docker/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/docker/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/docker/.manala/make/gmsl/gmsl b/roles/docker/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/docker/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/docker/.travis.yml b/roles/docker/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/docker/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/docker/CHANGELOG.md b/roles/docker/CHANGELOG.md deleted file mode 100644 index 059a157a5..000000000 --- a/roles/docker/CHANGELOG.md +++ /dev/null @@ -1,140 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.10] - 2021-06-16 -### Added -- Handle containers labels option - -## [2.0.9] - 2021-06-16 -### Added -- Handle containers etc_hosts option - -## [2.0.8] - 2020-12-18 -### Added -- `ignore` containers state -- Dict based daemon config - -### Changed -- Flatten containers array -- Deprecate dict's array daemon config - -## [2.0.7] - 2020-09-04 -### Added -- Allow applications templates - -## [2.0.6] - 2020-08-26 -### Changed -- Explicit file permissions - -## [2.0.5] - 2020-06-09 -### Changed -- Install dependencies based on python version - -## [2.0.4] - 2020-04-23 -### Added -- Handle log_driver and log_options options - -## [2.0.3] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.2] - 2019-12-27 -### Added -- Handle network_mode option - -## [2.0.1] - 2019-11-21 -### Added -- Handle capabilities option - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.17] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.16] - 2019-03-19 -### Added -- Handle pull option -- Handle privileged option - -## [1.0.15] - 2018-11-16 -### Fixed -- Keep legacy sysvinit services handling in ansible 2.6+ - -## [1.0.14] - 2018-11-12 -### Added -- Handle containers memory & ulimits options - -## [1.0.13] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.12] - 2018-06-29 -### Added -- Handle containers entrypoint/command - -## [1.0.11] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.10] - 2018-02-22 -### Added -- Handle containers - -## [1.0.9] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.8] - 2017-11-09 -### Added -- Handle daemon config - -### Fixed -- Use the most safe storage-driver (vfs) in tests, to avoid platform dependant issues - -## [1.0.7] - 2017-10-28 -### Fixed -- Repository key/url and package name - -### Changed -- Fix ansible 2.3 warnings "when statements should not include jinja2 templating delimiters" - -## [1.0.6] - 2017-06-02 -### Added -- manala/openl10n-cli application pattern - -## [1.0.5] - 2017-03-16 -### Fixed -- Better tty/interative applications handling - -## [1.0.4] - 2017-03-15 -### Fixed -- manala/security-checker application pattern image - -## [1.0.3] - 2017-03-14 -### Added -- manala/parallel-lint application pattern - -## [1.0.2] - 2017-03-14 -### Changed -- Introduce applications environment - -## [1.0.1] - 2017-02-23 -### Added -- Handle applications -- Handle update - -## [1.0.0] - 2016-12-29 -### Added -- Install docker diff --git a/roles/docker/Makefile b/roles/docker/Makefile deleted file mode 100644 index e9c53da9b..000000000 --- a/roles/docker/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.docker -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/docker/README.md b/roles/docker/README.md index 2b0ea65d5..336ac39d5 100644 --- a/roles/docker/README.md +++ b/roles/docker/README.md @@ -1,13 +1,3 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - # Ansible Role: Docker [![Build Status](https://travis-ci.org/manala/ansible-role-docker.svg?branch=master)](https://travis-ci.org/manala/ansible-role-docker) :exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: @@ -26,42 +16,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.docker -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.docker -``` - -## Role Handlers - -| Name | Type | Description | -| ---------------- | ------- | ---------------------- | -| `docker restart` | Service | Restart Docker service | +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -### Definition - -| Name | Default | Type | Description | -| ---------------------------------------- | ------------------------- | ------- | ------------------------------------------ | -| `manala_docker_install_packages` | ~ | Array | Dependency packages to install | -| `manala_docker_install_packages_default` | ['docker-ce'] | Array | Default dependency packages to install | -| `manala_docker_applications_dir` | '/usr/local/bin' | String | Applications dir path | -| `manala_docker_applications_template` | 'applications/_default.j2' | String | Applications default template path | -| `manala_docker_applications` | [] | Array | Applications | -| `manala_docker_containers` | [] | Array | Containers | -| `manala_docker_config_daemon_file` | '/etc/docker/daemon.json' | String | Daemon configuration file path | -| `manala_docker_config_daemon_template` | 'config_daemon/empty.j2' | String | Daemon configuration default template path | -| `manala_docker_config_daemon` | ~ | Array | Daemon configuration | -| `manala_docker.update` | false | Boolean | Update images | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example @@ -89,13 +48,6 @@ manala_docker_config_daemon: | } ``` -Daemon config using dict's array parameters (deprecated): - -```yaml -manala_docker_config_daemon: - - storage-driver: vfs -``` - ```yaml manala_docker_applications: - hello-world @@ -150,13 +102,16 @@ manala: ```yaml - hosts: servers - roles: - - role: manala.docker + tasks: + - import_role: + name: manala.roles. ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/docker/handlers/main.yml b/roles/docker/handlers/main.yml index c244c99e9..3fb678a89 100644 --- a/roles/docker/handlers/main.yml +++ b/roles/docker/handlers/main.yml @@ -2,5 +2,7 @@ - name: docker restart service: - name: docker + name: "{{ item }}" state: restarted + loop: + - docker diff --git a/roles/docker/lookup_plugins/.gitignore b/roles/docker/lookup_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/docker/lookup_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/docker/lookup_plugins/manala_docker_applications.py b/roles/docker/lookup_plugins/manala_docker_applications.py deleted file mode 100644 index 87d871c2a..000000000 --- a/roles/docker/lookup_plugins/manala_docker_applications.py +++ /dev/null @@ -1,80 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.module_utils.six import string_types -from ansible.errors import AnsibleError - -class LookupModule(LookupBase): - - def run(self, terms, variables=None, **kwargs): - - results = [] - - # Patterns - patterns = terms[1] - - itemDefault = { - 'tag': None, - 'rm': None, - 'interactive': None, - 'tty': None, - 'command': None, - 'volumes': {}, - 'environment': {}, - 'workdir': None - } - - for term in self._flatten(terms[0]): - - items = [] - - # Short syntax - if isinstance(term, string_types): - item = itemDefault.copy() - - item.update({ - 'image': term.split(':')[0], - 'application': ((term.split('/')[1]).split(':')[0]) - if len(term.split('/')) > 1 else - (term.split(':')[0]) - }) - - # Pattern - if term.split(':')[0] in patterns: - item.update(patterns.get(term.split(':')[0])) - - # Tag - if len(term.split(':')) > 1: - item.update({ - 'tag': term.split(':')[1] - }) - else: - - # Must be a dict - if not isinstance(term, dict): - raise AnsibleError('Expect a dict') - - # Check index key - if 'application' not in term: - raise AnsibleError('Expect "application" key') - - item = itemDefault.copy() - - item.update(term) - - items.append(item) - - # Merge by index key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['application'] == item['application']: - results[i] = item - itemFound = True - break - - if not itemFound: - results.append(item) - - return results diff --git a/roles/docker/meta/main.yml b/roles/docker/meta/main.yml index eae23ee61..7367798f6 100644 --- a/roles/docker/meta/main.yml +++ b/roles/docker/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: docker - author: Manala - company: Manala - description: Handle Docker - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: docker + author: Manala + company: Manala + description: Handle Docker + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - docker diff --git a/roles/docker/tasks/applications.yml b/roles/docker/tasks/applications.yml index 75528952d..c4dcdcc00 100644 --- a/roles/docker/tasks/applications.yml +++ b/roles/docker/tasks/applications.yml @@ -8,8 +8,7 @@ group: root mode: "0755" loop: "{{ query( - 'manala_docker_applications', - manala_docker_applications, - manala_docker_applications_patterns - ) - }}" + 'manala.roles.docker_applications', + manala_docker_applications, + manala_docker_applications_patterns + ) }}" diff --git a/roles/docker/tasks/config_daemon.yml b/roles/docker/tasks/config_daemon.yml index 32b00339f..b6fc281be 100644 --- a/roles/docker/tasks/config_daemon.yml +++ b/roles/docker/tasks/config_daemon.yml @@ -1,5 +1,15 @@ --- +- name: config_daemon > Directory + file: + path: "{{ manala_docker_config_daemon_file|dirname }}" + state: directory + owner: root + group: root + mode: "0755" + when: manala_docker_config_daemon_template + or manala_docker_config_daemon + - name: config_daemon > Template template: src: "{{ manala_docker_config_daemon_template|default('config_daemon/_default.j2', true) }}" @@ -8,6 +18,6 @@ group: root mode: "0644" when: manala_docker_config_daemon_template - or manala_docker_config_daemon + or manala_docker_config_daemon notify: - docker restart diff --git a/roles/docker/tasks/containers.yml b/roles/docker/tasks/containers.yml index 79c1f64fa..e11e5e07d 100644 --- a/roles/docker/tasks/containers.yml +++ b/roles/docker/tasks/containers.yml @@ -30,7 +30,7 @@ etc_hosts: "{{ item.etc_hosts|default(omit) }}" labels: "{{ item.labels|default(omit) }}" loop: "{{ - manala_docker_containers | flatten | selectattr('state', 'undefined') | list - + - manala_docker_containers | flatten | selectattr('state', 'defined') | rejectattr('state', 'equalto', 'ignore') | list + manala_docker_containers + | flatten + | manala.roles.staten_ignore }}" diff --git a/roles/docker/tasks/install.yml b/roles/docker/tasks/install.yml index 6da04f3a0..b62ad169b 100644 --- a/roles/docker/tasks/install.yml +++ b/roles/docker/tasks/install.yml @@ -2,13 +2,18 @@ - name: install > Packages apt: - name: "{{ + name: "{{ item }}" + install_recommends: false + update_cache: true + cache_valid_time: 3600 + loop: + - "{{ manala_docker_install_packages|default(manala_docker_install_packages_default, True) + (manala_docker_containers|length > 0)|ternary( - (ansible_python.version.major == 2) | ternary(['python-docker'], ['python3-docker']), - [] + (ansible_python.version.major == 2)|ternary( + ['python-docker'], + ['python3-docker'] + ), + [] ) }}" - install_recommends: false - update_cache: true - cache_valid_time: 3600 diff --git a/roles/docker/tasks/services.yml b/roles/docker/tasks/services.yml index 10aa9b1f6..4ce80dbd8 100644 --- a/roles/docker/tasks/services.yml +++ b/roles/docker/tasks/services.yml @@ -5,8 +5,5 @@ name: "{{ item }}" state: started enabled: true - # Keep legacy sysvinit services handling in ansible 2.6+ - # See: https://github.com/ansible/ansible/pull/48724 - use: "{{ (ansible_service_mgr == 'sysvinit')|ternary('service', omit) }}" - with_items: + loop: - docker diff --git a/roles/docker/templates/config_daemon/_default.j2 b/roles/docker/templates/config_daemon/_default.j2 index e19594a60..26b5d5f50 100644 --- a/roles/docker/templates/config_daemon/_default.j2 +++ b/roles/docker/templates/config_daemon/_default.j2 @@ -2,16 +2,7 @@ {%- if config is mapping -%} -{{ config | to_nice_json }} - -{%- elif config is iterable and config is not string -%} - -{#- Deprecated -#} -{%- import '_macros.j2' as macros with context -%} - -{ -{{ macros.config(config, [], 4) }} -} +{{ config | manala.roles.json }} {%- else -%} diff --git a/roles/docker/templates/config_daemon/_macros.j2 b/roles/docker/templates/config_daemon/_macros.j2 deleted file mode 100644 index 2b249a1a6..000000000 --- a/roles/docker/templates/config_daemon/_macros.j2 +++ /dev/null @@ -1,63 +0,0 @@ -{#- Deprecated -#} - -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {%- set outer_loop = loop -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }}{% if not outer_loop.last %},{{ '\n' }}{% endif %} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %} {% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %} {% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {{ _config_parameter_key(key)|indent(indent, true) }}: {{ _config_parameter_value(value) }} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - "{{ key }}" -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {%- if value is sameas none -%} - {%- elif value is sameas true -%} - true - {%- elif value is sameas false -%} - false - {%- elif value is string -%} - "{{ value }}" - {%- elif value is number -%} - {{ value }} - {%- endif -%} -{%- endmacro -%} diff --git a/roles/docker/tests/.gitignore b/roles/docker/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/docker/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/docker/tests/0000_default.yml b/roles/docker/tests/0000_default.yml deleted file mode 100644 index 3369649ea..000000000 --- a/roles/docker/tests/0000_default.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/docker.yml - - - block: - - import_role: - name: manala.docker - vars: - manala_docker_config_daemon: - storage-driver: vfs - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/docker/tests/0200_config_daemon.goss.yml b/roles/docker/tests/0200_config_daemon.goss.yml deleted file mode 100644 index 9e11dd817..000000000 --- a/roles/docker/tests/0200_config_daemon.goss.yml +++ /dev/null @@ -1,44 +0,0 @@ ---- - -file: - /etc/docker/daemon.json: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "{" - - " \"experimental\": false," - - " \"storage-driver\": \"vfs\"" - - "}" - tmp/config_daemon/default/default_deprecated.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "{" - - " \"storage-driver\": \"vfs\"," - - " \"experimental\": false" - - "}" - tmp/config_daemon/default/default_content.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "{" - - " \"storage-driver\": \"vfs\"," - - " \"experimental\": false" - - "}" - tmp/config_daemon/default/template.conf: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Config daemon foo" diff --git a/roles/docker/tests/0200_config_daemon.yml b/roles/docker/tests/0200_config_daemon.yml deleted file mode 100644 index 78d98cd2e..000000000 --- a/roles/docker/tests/0200_config_daemon.yml +++ /dev/null @@ -1,54 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/docker.yml - - - block: - - file: - path: tmp/config_daemon/default - state: "{{ item }}" - loop: [absent, directory] - # Default - - import_role: - # Play role fully on first run, so that handlers don't breaks - name: manala.docker - vars: - manala_docker_config_daemon: - storage-driver: vfs - experimental: false - # Default - Deprecated - - import_role: - name: manala.docker - tasks_from: config_daemon - vars: - manala_docker_config_daemon_file: tmp/config_daemon/default/default_deprecated.conf - manala_docker_config_daemon: - - storage-driver: vfs - - experimental: false - # Default - Content - - import_role: - name: manala.docker - tasks_from: config_daemon - vars: - manala_docker_config_daemon_file: tmp/config_daemon/default/default_content.conf - manala_docker_config_daemon: | - { - "storage-driver": "vfs", - "experimental": false - } - # Template - - import_role: - name: manala.docker - tasks_from: config_daemon - vars: - manala_docker_config_daemon_file: tmp/config_daemon/default/template.conf - manala_docker_config_daemon_template: config_daemon/foo.json.j2 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/docker/tests/0400_applications.goss.yml b/roles/docker/tests/0400_applications.goss.yml deleted file mode 100644 index 3f434bc49..000000000 --- a/roles/docker/tests/0400_applications.goss.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- - -file: - /usr/local/bin/hello-world: - exists: true - filetype: file - owner: root - group: root - mode: "0755" - /usr/local/bin/npm: - exists: true - filetype: file - owner: root - group: root - mode: "0755" - /usr/local/bin/audiowaveform: - exists: true - filetype: file - owner: root - group: root - mode: "0755" - -command: - hello-world: - exit-status: 0 - timeout: 60000 - stdout: - - Hello from Docker! - npm --version: - exit-status: 0 - timeout: 60000 - audiowaveform --version: - exit-status: 0 - timeout: 60000 - stdout: - - AudioWaveform v1.4.2 diff --git a/roles/docker/tests/0400_applications.yml b/roles/docker/tests/0400_applications.yml deleted file mode 100644 index 6e1dcc511..000000000 --- a/roles/docker/tests/0400_applications.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/docker.yml - - - block: - # Default - - import_role: - name: manala.docker - vars: - manala_docker_config_daemon: - storage-driver: vfs - manala_docker_applications: - - hello-world - - application: npm - image: node - command: npm - tag: alpine - - application: audiowaveform - template: applications/audiowaveform.j2 - version: 1.4.2 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/docker/tests/0500_containers.yml b/roles/docker/tests/0500_containers.yml deleted file mode 100644 index e6ce88153..000000000 --- a/roles/docker/tests/0500_containers.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian:!debian.jessie - become: true - tasks: - - - block: - - import_tasks: pre_tasks/docker.yml - - - block: - # Default - - import_role: - name: manala.docker - vars: - manala_docker_config_daemon: - storage-driver: vfs - manala_docker_containers: - - name: hello-world - image: hello-world - - name: busybox - image: busybox - state: ignore - # Flatten - - - - name: alpine - image: alpine - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/docker/tests/0600_update.yml b/roles/docker/tests/0600_update.yml deleted file mode 100644 index edbe6e62b..000000000 --- a/roles/docker/tests/0600_update.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/docker.yml - - - block: - - import_role: - name: manala.docker - vars: - manala_docker_config_daemon: - storage-driver: vfs - manala_docker: - update: true diff --git a/roles/docker/tests/pre_tasks/apt_keys/docker.pgp b/roles/docker/tests/pre_tasks/apt_keys/docker.pgp deleted file mode 100644 index b516362ff..000000000 --- a/roles/docker/tests/pre_tasks/apt_keys/docker.pgp +++ /dev/null @@ -1,63 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1 - -mQINBFit2ioBEADhWpZ8/wvZ6hUTiXOwQHXMAlaFHcPH9hAtr4F1y2+OYdbtMuth -lqqwp028AqyY+PRfVMtSYMbjuQuu5byyKR01BbqYhuS3jtqQmljZ/bJvXqnmiVXh -38UuLa+z077PxyxQhu5BbqntTPQMfiyqEiU+BKbq2WmANUKQf+1AmZY/IruOXbnq -L4C1+gJ8vfmXQt99npCaxEjaNRVYfOS8QcixNzHUYnb6emjlANyEVlZzeqo7XKl7 -UrwV5inawTSzWNvtjEjj4nJL8NsLwscpLPQUhTQ+7BbQXAwAmeHCUTQIvvWXqw0N -cmhh4HgeQscQHYgOJjjDVfoY5MucvglbIgCqfzAHW9jxmRL4qbMZj+b1XoePEtht -ku4bIQN1X5P07fNWzlgaRL5Z4POXDDZTlIQ/El58j9kp4bnWRCJW0lya+f8ocodo -vZZ+Doi+fy4D5ZGrL4XEcIQP/Lv5uFyf+kQtl/94VFYVJOleAv8W92KdgDkhTcTD -G7c0tIkVEKNUq48b3aQ64NOZQW7fVjfoKwEZdOqPE72Pa45jrZzvUFxSpdiNk2tZ -XYukHjlxxEgBdC/J3cMMNRE1F4NCA3ApfV1Y7/hTeOnmDuDYwr9/obA8t016Yljj -q5rdkywPf4JF8mXUW5eCN1vAFHxeg9ZWemhBtQmGxXnw9M+z6hWwc6ahmwARAQAB -tCtEb2NrZXIgUmVsZWFzZSAoQ0UgZGViKSA8ZG9ja2VyQGRvY2tlci5jb20+iQI3 -BBMBCgAhBQJYrefAAhsvBQsJCAcDBRUKCQgLBRYCAwEAAh4BAheAAAoJEI2BgDwO -v82IsskP/iQZo68flDQmNvn8X5XTd6RRaUH33kXYXquT6NkHJciS7E2gTJmqvMqd -tI4mNYHCSEYxI5qrcYV5YqX9P6+Ko+vozo4nseUQLPH/ATQ4qL0Zok+1jkag3Lgk -jonyUf9bwtWxFp05HC3GMHPhhcUSexCxQLQvnFWXD2sWLKivHp2fT8QbRGeZ+d3m -6fqcd5Fu7pxsqm0EUDK5NL+nPIgYhN+auTrhgzhK1CShfGccM/wfRlei9Utz6p9P -XRKIlWnXtT4qNGZNTN0tR+NLG/6Bqd8OYBaFAUcue/w1VW6JQ2VGYZHnZu9S8LMc -FYBa5Ig9PxwGQOgq6RDKDbV+PqTQT5EFMeR1mrjckk4DQJjbxeMZbiNMG5kGECA8 -g383P3elhn03WGbEEa4MNc3Z4+7c236QI3xWJfNPdUbXRaAwhy/6rTSFbzwKB0Jm -ebwzQfwjQY6f55MiI/RqDCyuPj3r3jyVRkK86pQKBAJwFHyqj9KaKXMZjfVnowLh -9svIGfNbGHpucATqREvUHuQbNnqkCx8VVhtYkhDb9fEP2xBu5VvHbR+3nfVhMut5 -G34Ct5RS7Jt6LIfFdtcn8CaSas/l1HbiGeRgc70X/9aYx/V/CEJv0lIe8gP6uDoW -FPIZ7d6vH+Vro6xuWEGiuMaiznap2KhZmpkgfupyFmplh0s6knymuQINBFit2ioB -EADneL9S9m4vhU3blaRjVUUyJ7b/qTjcSylvCH5XUE6R2k+ckEZjfAMZPLpO+/tF -M2JIJMD4SifKuS3xck9KtZGCufGmcwiLQRzeHF7vJUKrLD5RTkNi23ydvWZgPjtx -Q+DTT1Zcn7BrQFY6FgnRoUVIxwtdw1bMY/89rsFgS5wwuMESd3Q2RYgb7EOFOpnu -w6da7WakWf4IhnF5nsNYGDVaIHzpiqCl+uTbf1epCjrOlIzkZ3Z3Yk5CM/TiFzPk -z2lLz89cpD8U+NtCsfagWWfjd2U3jDapgH+7nQnCEWpROtzaKHG6lA3pXdix5zG8 -eRc6/0IbUSWvfjKxLLPfNeCS2pCL3IeEI5nothEEYdQH6szpLog79xB9dVnJyKJb -VfxXnseoYqVrRz2VVbUI5Blwm6B40E3eGVfUQWiux54DspyVMMk41Mx7QJ3iynIa -1N4ZAqVMAEruyXTRTxc9XW0tYhDMA/1GYvz0EmFpm8LzTHA6sFVtPm/ZlNCX6P1X -zJwrv7DSQKD6GGlBQUX+OeEJ8tTkkf8QTJSPUdh8P8YxDFS5EOGAvhhpMBYD42kQ -pqXjEC+XcycTvGI7impgv9PDY1RCC1zkBjKPa120rNhv/hkVk/YhuGoajoHyy4h7 -ZQopdcMtpN2dgmhEegny9JCSwxfQmQ0zK0g7m6SHiKMwjwARAQABiQQ+BBgBCAAJ -BQJYrdoqAhsCAikJEI2BgDwOv82IwV0gBBkBCAAGBQJYrdoqAAoJEH6gqcPyc/zY -1WAP/2wJ+R0gE6qsce3rjaIz58PJmc8goKrir5hnElWhPgbq7cYIsW5qiFyLhkdp -YcMmhD9mRiPpQn6Ya2w3e3B8zfIVKipbMBnke/ytZ9M7qHmDCcjoiSmwEXN3wKYI -mD9VHONsl/CG1rU9Isw1jtB5g1YxuBA7M/m36XN6x2u+NtNMDB9P56yc4gfsZVES -KA9v+yY2/l45L8d/WUkUi0YXomn6hyBGI7JrBLq0CX37GEYP6O9rrKipfz73XfO7 -JIGzOKZlljb/D9RX/g7nRbCn+3EtH7xnk+TK/50euEKw8SMUg147sJTcpQmv6UzZ -cM4JgL0HbHVCojV4C/plELwMddALOFeYQzTif6sMRPf+3DSj8frbInjChC3yOLy0 -6br92KFom17EIj2CAcoeq7UPhi2oouYBwPxh5ytdehJkoo+sN7RIWua6P2WSmon5 -U888cSylXC0+ADFdgLX9K2zrDVYUG1vo8CX0vzxFBaHwN6Px26fhIT1/hYUHQR1z -VfNDcyQmXqkOnZvvoMfz/Q0s9BhFJ/zU6AgQbIZE/hm1spsfgvtsD1frZfygXJ9f -irP+MSAI80xHSf91qSRZOj4Pl3ZJNbq4yYxv0b1pkMqeGdjdCYhLU+LZ4wbQmpCk -SVe2prlLureigXtmZfkqevRz7FrIZiu9ky8wnCAPwC7/zmS18rgP/17bOtL4/iIz -QhxAAoAMWVrGyJivSkjhSGx1uCojsWfsTAm11P7jsruIL61ZzMUVE2aM3Pmj5G+W -9AcZ58Em+1WsVnAXdUR//bMmhyr8wL/G1YO1V3JEJTRdxsSxdYa4deGBBY/Adpsw -24jxhOJR+lsJpqIUeb999+R8euDhRHG9eFO7DRu6weatUJ6suupoDTRWtr/4yGqe -dKxV3qQhNLSnaAzqW/1nA3iUB4k7kCaKZxhdhDbClf9P37qaRW467BLCVO/coL3y -Vm50dwdrNtKpMBh3ZpbB1uJvgi9mXtyBOMJ3v8RZeDzFiG8HdCtg9RvIt/AIFoHR -H3S+U79NT6i0KPzLImDfs8T7RlpyuMc4Ufs8ggyg9v3Ae6cN3eQyxcK3w0cbBwsh -/nQNfsA6uu+9H7NhbehBMhYnpNZyrHzCmzyXkauwRAqoCbGCNykTRwsur9gS41TQ -M8ssD1jFheOJf3hODnkKU+HKjvMROl1DK7zdmLdNzA1cvtZH/nCC9KPj1z8QC47S -xx+dTZSx4ONAhwbS/LN3PoKtn8LPjY9NP9uDWI+TWYquS2U+KHDrBDlsgozDbs/O -jCxcpDzNmXpWQHEtHU7649OXHP7UeNST1mCUCH5qdank0V1iejF6/CfTFU4MfcrG -YT90qFF93M3v01BbxP+EIY2/9tiIPbrd -=0YYh ------END PGP PUBLIC KEY BLOCK----- diff --git a/roles/docker/tests/pre_tasks/backports.yml b/roles/docker/tests/pre_tasks/backports.yml deleted file mode 100644 index 0d3de0adb..000000000 --- a/roles/docker/tests/pre_tasks/backports.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -# Jessie repositories have been archived, meaning that some of them -# (backports, for instance) will remain invalid forever. -- name: Pre tasks > Backports apt repository validity - copy: - dest: /etc/apt/apt.conf.d/archive - content: | - Acquire::Check-Valid-Until "false"; - when: ansible_distribution_release in ['jessie'] - -- name: Pre tasks > Backports apt repository - apt_repository: - repo: deb http://{{ (ansible_distribution_release in ['jessie'])|ternary('archive', 'deb') }}.debian.org/debian {{ ansible_distribution_release }}-backports main diff --git a/roles/docker/tests/pre_tasks/docker.yml b/roles/docker/tests/pre_tasks/docker.yml deleted file mode 100644 index ff6e8ce68..000000000 --- a/roles/docker/tests/pre_tasks/docker.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Pre tasks > Docker apt key - apt_key: - file: pre_tasks/apt_keys/docker.pgp - id: 0EBFCD88 - -- name: Pre tasks > Docker apt repository - apt_repository: - repo: deb [arch=amd64] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable diff --git a/roles/docker/tests/templates/applications/audiowaveform.j2 b/roles/docker/tests/templates/applications/audiowaveform.j2 deleted file mode 100644 index 40b087eb0..000000000 --- a/roles/docker/tests/templates/applications/audiowaveform.j2 +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env sh - -docker run \ - --rm \ - elao/audiowaveform:{{ item.version|mandatory }} \ - "$@" diff --git a/roles/docker/tests/templates/config_daemon/foo.json.j2 b/roles/docker/tests/templates/config_daemon/foo.json.j2 deleted file mode 100644 index f23bbb490..000000000 --- a/roles/docker/tests/templates/config_daemon/foo.json.j2 +++ /dev/null @@ -1 +0,0 @@ -Config daemon foo diff --git a/roles/docker/tests/tmp/.gitignore b/roles/docker/tests/tmp/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/roles/docker/tests/tmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/roles/elasticsearch/.gitignore b/roles/elasticsearch/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/elasticsearch/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/elasticsearch/.manala/make/Makefile b/roles/elasticsearch/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/elasticsearch/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/elasticsearch/.manala/make/Makefile.docker b/roles/elasticsearch/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/elasticsearch/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/elasticsearch/.manala/make/Makefile.host b/roles/elasticsearch/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/elasticsearch/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/elasticsearch/.manala/make/Makefile.manala b/roles/elasticsearch/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/elasticsearch/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/elasticsearch/.manala/make/Makefile.travis b/roles/elasticsearch/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/elasticsearch/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/elasticsearch/.manala/make/gmsl/__gmsl b/roles/elasticsearch/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/elasticsearch/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/elasticsearch/.manala/make/gmsl/gmsl b/roles/elasticsearch/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/elasticsearch/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/elasticsearch/.travis.yml b/roles/elasticsearch/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/elasticsearch/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/elasticsearch/CHANGELOG.md b/roles/elasticsearch/CHANGELOG.md deleted file mode 100644 index 9c1fd6578..000000000 --- a/roles/elasticsearch/CHANGELOG.md +++ /dev/null @@ -1,106 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.5] - 2021-03-26 -### Fixed -- Use absolute path when including sub templates - -## [2.0.4] - 2021-01-07 -### Removed -- Drop 1.5/1.6 support - -### Added -- Yaml config filter -- Version dependent config/environment files group & mode - -### Changed -- Use environment filter -- Deprecate dict's array config/environment templates - -## [2.0.3] - 2020-09-11 -### Fixed -- Fix explicit file permissions - -## [2.0.2] - 2020-08-28 -### Changed -- Explicit file permissions - -## [2.0.1] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support -- Requirements check task - -## [1.0.11] - 2019-10-29 -### Fixed -- Cleanup version comparisons - -## [1.0.10] - 2019-10-24 -### Added -- Debian buster support -- Support version 7 - -## [1.0.9] - 2019-09-27 -### Added -- Handle environment file - -### Fixed -- Version 7 base config template - -## [1.0.8] - 2019-09-20 -### Added -- Support version 7 - -## [1.0.7] - 2019-05-21 -### Fixed -- Restart service after plugin installations - -## [1.0.6] - 2018-11-16 -### Fixed -- Keep legacy sysvinit services handling in ansible 2.6+ - -## [1.0.5] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.4] - 2018-06-26 -### Removed -- Elasticsearch < 2.0.0 support on debian stretch - -## [1.0.3] - 2018-06-05 -### Added -- Handle dependency packages to install -- Support version 6 - -### Changed -- Replace deprecated jinja tests used as filters -- Add curl to pretty in Goss tests to check installed version -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.2] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.1] - 2017-10-17 -### Added -- Handle version (autodetect or fixed) -- Version based configurations -- Version based / distribution release requirements -- Version based tests -- Support version 5 - -## [1.0.0] - 2017-06-21 -### Added -- Handle installation -- Handle config -- Handle services -- Handle plugins diff --git a/roles/elasticsearch/Makefile b/roles/elasticsearch/Makefile deleted file mode 100644 index 99ea64188..000000000 --- a/roles/elasticsearch/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.elasticsearch -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/elasticsearch/README.md b/roles/elasticsearch/README.md index 964f09d4b..0239a1d3d 100644 --- a/roles/elasticsearch/README.md +++ b/roles/elasticsearch/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Elasticsearch [![Build Status](https://travis-ci.org/manala/ansible-role-elasticsearch.svg?branch=master)](https://travis-ci.org/manala/ansible-role-elasticsearch) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Elasticsearch This role will deal with the setup of [Elasticsearch](https://www.elastic.co/fr/products/elasticsearch). -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,42 +14,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.elasticsearch -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.elasticsearch -``` - -## Role Handlers - -| Name | Type | Description | -| ----------------------- | ------- | --------------------- | -| `elasticsearch restart` | Service | Restart elasticsearch | +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -### Definition - -| Name | Default | Type | Description | -| ----------------------------------------------- | -------------------------------------- | ------------ | -------------------------------------- | -| `manala_elasticsearch_version` | ~ | String | Version (autodetect if null) | -| `manala_elasticsearch_install_packages` | ~ | Array | Dependency packages to install | -| `manala_elasticsearch_install_packages_default` | ['elasticsearch'] | Array | Default dependency packages to install | -| `manala_elasticsearch_config_file` | '/etc/elasticsearch/elasticsearch.yml' | String | Configuration file path | -| `manala_elasticsearch_config_template` | ~ | String | Configuration file template path | -| `manala_elasticsearch_config` | ~ | Array/String | Configuration | -| `manala_elasticsearch_plugins` | [] | Array | Plugins | -| `manala_elasticsearch_environment_file` | '/etc/default/elasticsearch' | String | Environment file path | -| `manala_elasticsearch_environment_template` | ~ | String | Environment file template path | -| `manala_elasticsearch_environment` | ~ | Array/String | Environment | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Example @@ -94,13 +51,6 @@ manala_elasticsearch_config: | path.data: /foo/bar ``` -Use dict's array parameters (deprecated): -```yaml -manala_elasticsearch_config: - - cluster.name: foo - - path.data: /foo/bar -``` - #### Environment Use elasticsearch default main environment template (recommended): @@ -122,12 +72,6 @@ manala_elasticsearch_environment: | ES_JAVA_OPTS="-Xms1g -Xmx1g" ``` -Use dict's array parameters (deprecated): -```yaml -manala_elasticsearch_environment: - - ES_JAVA_OPTS: -Xms1g -Xmx1g -``` - #### Plugins ```yaml @@ -143,13 +87,16 @@ manala_elasticsearch_plugins: ```yaml - hosts: servers - roles: - - role: manala.elasticsearch + tasks: + - import_role: + name: manala.roles.elasticsearch ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/elasticsearch/defaults/main.yml b/roles/elasticsearch/defaults/main.yml index 7d299b99c..ec8a96c51 100644 --- a/roles/elasticsearch/defaults/main.yml +++ b/roles/elasticsearch/defaults/main.yml @@ -1,9 +1,10 @@ --- -# Elasticsearch version. Available values are '~' (autodetect), '1.7', '2', '5', '6', '7' +# Available values: '~' (autodetect), 2, 5, 6, 7, ... manala_elasticsearch_version: ~ # Install +# Note: First package name in list is used for version autodetection manala_elasticsearch_install_packages: ~ manala_elasticsearch_install_packages_default: - elasticsearch diff --git a/roles/elasticsearch/filter_plugins/.gitignore b/roles/elasticsearch/filter_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/elasticsearch/filter_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/elasticsearch/filter_plugins/manala_environment.py b/roles/elasticsearch/filter_plugins/manala_environment.py deleted file mode 100644 index 57a6e4b8d..000000000 --- a/roles/elasticsearch/filter_plugins/manala_environment.py +++ /dev/null @@ -1,53 +0,0 @@ -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -from ansible.errors import AnsibleFilterError -from ansible.module_utils.six import iteritems, string_types - -from numbers import Number - - -def environment(parameters, exclude=[]): - if not isinstance(parameters, dict): - raise AnsibleFilterError('manala_environment expects a dict but was given a %s' % type(parameters)) - [parameters.pop(key, None) for key in exclude] - result = '' - for key in sorted(parameters): - parameter = environment_parameter(parameters, key) - if parameter: - result += '\n%s' % parameter - return result.lstrip() - -def environment_parameter(parameters, key, required=False, default=None, comment=False): - if not isinstance(parameters, dict): - raise AnsibleFilterError('manala_environment_parameter parameters expects a dict but was given a %s' % type(parameters)) - if not isinstance(key, string_types): - raise AnsibleFilterError('manala_environment_parameter key expects a string but was given a %s' % type(key)) - if required and key not in parameters: - raise AnsibleFilterError('manala_environment_parameter requires a value for key %s' % key) - result = '' - value = parameters.get(key, default) - if isinstance(value, string_types): - result = '%s="%s"' % (key, value) - elif isinstance(value, Number): - result = '%s=%s' % (key, value) - else: - AnsibleFilterError('manala_environment_parameter value of an unknown type %s' % type(value)) - if key not in parameters: - if comment is True: - result = '#' + result.replace('\n', '\n#') - elif isinstance(comment, string_types): - result = comment - return result - - -class FilterModule(object): - ''' Manala environment jinja2 filters ''' - - def filters(self): - filters = { - 'manala_environment': environment, - 'manala_environment_parameter': environment_parameter, - } - - return filters diff --git a/roles/elasticsearch/filter_plugins/manala_yaml.py b/roles/elasticsearch/filter_plugins/manala_yaml.py deleted file mode 100644 index 7f4a9d9e1..000000000 --- a/roles/elasticsearch/filter_plugins/manala_yaml.py +++ /dev/null @@ -1,58 +0,0 @@ -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -from ansible.errors import AnsibleFilterError -from ansible.module_utils.six import iteritems, string_types -from ansible.plugins.filter.core import to_nice_yaml - -def yaml(parameters, exclude=[]): - if not isinstance(parameters, dict): - raise AnsibleFilterError('manala_yaml expects a dict but was given a %s' % type(parameters)) - [parameters.pop(key, None) for key in exclude] - result = '' - for key in sorted(parameters): - parameter = yaml_parameter(parameters, key) - if parameter: - result += '\n%s' % parameter - return result.lstrip() - -def yaml_parameter(parameters, key, required=False, default=None, comment=False): - if not isinstance(parameters, dict): - raise AnsibleFilterError('manala_yaml_parameter parameters expects a dict but was given a %s' % type(parameters)) - if not isinstance(key, string_types): - raise AnsibleFilterError('manala_yaml_parameter key expects a string but was given a %s' % type(key)) - if required and key not in parameters: - raise AnsibleFilterError('manala_yaml_parameter requires a value for key %s' % key) - value = parameters.get(key, default) - result = to_nice_yaml({key: value},).rstrip() - if key not in parameters: - if comment is True: - result = '#' + result.replace('\n', '\n#') - elif isinstance(comment, string_types): - result = comment - return result - -def yaml_flatten(parameters, parent='', separator='.'): - if not isinstance(parameters, dict): - raise AnsibleFilterError('manala_yaml_flatten expects a dict but was given a %s' % type(parameters)) - items = [] - for key, value in parameters.items(): - key = (parent + separator + key) if parent else key - if isinstance(value, dict): - items.extend(yaml_flatten(value, key, separator=separator).items()) - else: - items.append((key, value)) - return dict(items) - - -class FilterModule(object): - ''' Manala yaml jinja2 filters ''' - - def filters(self): - filters = { - 'manala_yaml': yaml, - 'manala_yaml_parameter': yaml_parameter, - 'manala_yaml_flatten': yaml_flatten, - } - - return filters diff --git a/roles/elasticsearch/handlers/main.yml b/roles/elasticsearch/handlers/main.yml index 006c6c771..e67fba023 100644 --- a/roles/elasticsearch/handlers/main.yml +++ b/roles/elasticsearch/handlers/main.yml @@ -2,5 +2,7 @@ - name: elasticsearch restart service: - name: elasticsearch + name: "{{ item }}" state: restarted + loop: + - elasticsearch diff --git a/roles/elasticsearch/meta/main.yml b/roles/elasticsearch/meta/main.yml index b81135448..67c5dcf24 100644 --- a/roles/elasticsearch/meta/main.yml +++ b/roles/elasticsearch/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: elasticsearch - author: Manala - company: Manala - description: Handle elasticsearch - license: MIT - min_ansible_version: 2.5.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: elasticsearch + author: Manala + company: Manala + description: Handle elasticsearch + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - development - elasticsearch diff --git a/roles/elasticsearch/tasks/config.yml b/roles/elasticsearch/tasks/config.yml index 77724718f..d0fad5c73 100644 --- a/roles/elasticsearch/tasks/config.yml +++ b/roles/elasticsearch/tasks/config.yml @@ -5,16 +5,12 @@ src: "{{ manala_elasticsearch_config_template|default('config/_default.j2', true) }}" dest: "{{ manala_elasticsearch_config_file }}" owner: root - group: "{{ - 'root' if (manala_elasticsearch_version is version('1.7', '=')) else - 'elasticsearch' - }}" + group: elasticsearch mode: "{{ - '0644' if (manala_elasticsearch_version is version('1.7', '=')) else '0750' if (manala_elasticsearch_version is version('2', '=')) else '0660' }}" when: manala_elasticsearch_config_template - or manala_elasticsearch_config + or manala_elasticsearch_config notify: - elasticsearch restart diff --git a/roles/elasticsearch/tasks/environment.yml b/roles/elasticsearch/tasks/environment.yml index 2d45a6d2a..b56a5aecb 100644 --- a/roles/elasticsearch/tasks/environment.yml +++ b/roles/elasticsearch/tasks/environment.yml @@ -14,6 +14,6 @@ '0660' }}" when: manala_elasticsearch_environment_template - or manala_elasticsearch_environment + or manala_elasticsearch_environment notify: - elasticsearch restart diff --git a/roles/elasticsearch/tasks/install.yml b/roles/elasticsearch/tasks/install.yml index 5e5e90bff..627e390d0 100644 --- a/roles/elasticsearch/tasks/install.yml +++ b/roles/elasticsearch/tasks/install.yml @@ -2,19 +2,27 @@ - name: install > Packages apt: - name: "{{ manala_elasticsearch_install_packages|default(manala_elasticsearch_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_elasticsearch_install_packages|default(manala_elasticsearch_install_packages_default, True) }}" - block: - - name: install > Version - shell: dpkg -s elasticsearch + - name: install > Parse version + command: > + dpkg -s + {{ manala_elasticsearch_install_packages|default(manala_elasticsearch_install_packages_default, True) | first }} register: __manala_elasticsearch_version changed_when: false - - name: install > Version + - name: install > Set version set_fact: - manala_elasticsearch_version: "{{ __manala_elasticsearch_version.stdout | regex_search('Version: (1\\.\\d|\\d)', '\\1') | first }}" + manala_elasticsearch_version: "{{ + __manala_elasticsearch_version.stdout + | regex_search('Version: (\\d+:)?(?P\\d+)', '\\g') + | first + }}" changed_when: false when: manala_elasticsearch_version is none check_mode: false diff --git a/roles/elasticsearch/tasks/plugins.yml b/roles/elasticsearch/tasks/plugins.yml index a9a8eb24c..4259f0170 100644 --- a/roles/elasticsearch/tasks/plugins.yml +++ b/roles/elasticsearch/tasks/plugins.yml @@ -4,6 +4,6 @@ elasticsearch_plugin: name: "{{ (item) if (item is string) else (item.name) }}" state: "{{ item.state|default('present') }}" - with_items: "{{ manala_elasticsearch_plugins }}" + loop: "{{ manala_elasticsearch_plugins }}" notify: - elasticsearch restart diff --git a/roles/elasticsearch/tasks/services.yml b/roles/elasticsearch/tasks/services.yml index be9df2a37..ecde36aa2 100644 --- a/roles/elasticsearch/tasks/services.yml +++ b/roles/elasticsearch/tasks/services.yml @@ -5,8 +5,5 @@ name: "{{ item }}" state: started enabled: true - # Keep legacy sysvinit services handling in ansible 2.6+ - # See: https://github.com/ansible/ansible/pull/48724 - use: "{{ (ansible_service_mgr == 'sysvinit')|ternary('service', omit) }}" - with_items: + loop: - elasticsearch diff --git a/roles/elasticsearch/templates/config/1.7/_base.j2 b/roles/elasticsearch/templates/config/1.7/_base.j2 deleted file mode 100644 index 86192ccf9..000000000 --- a/roles/elasticsearch/templates/config/1.7/_base.j2 +++ /dev/null @@ -1,447 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_elasticsearch_config -%} - -##################### Elasticsearch Configuration Example ##################### - -# This file contains an overview of various configuration settings, -# targeted at operations staff. Application developers should -# consult the guide at . -# -# The installation procedure is covered at -# . -# -# Elasticsearch comes with reasonable defaults for most settings, -# so you can try it out without bothering with configuration. -# -# Most of the time, these defaults are just fine for running a production -# cluster. If you're fine-tuning your cluster, or wondering about the -# effect of certain configuration option, please _do ask_ on the -# mailing list or IRC channel [http://elasticsearch.org/community]. - -# Any element in the configuration can be replaced with environment variables -# by placing them in ${...} notation. For example: -# -#node.rack: ${RACK_ENV_VAR} - -# For information on supported formats and syntax for the config file, see -# - - -################################### Cluster ################################### - -# Cluster name identifies your cluster for auto-discovery. If you're running -# multiple clusters on the same network, make sure you're using unique names. -# -{{ macros.config_row(config, 'cluster.name', '#cluster.name: elasticsearch', 0, true) }} - - -#################################### Node ##################################### - -# Node names are generated dynamically on startup, so you're relieved -# from configuring them manually. You can tie this node to a specific name: -# -{{ macros.config_row(config, 'node.name', '#node.name: "Franz Kafka"', 0, true) }} - -# Every node can be configured to allow or deny being eligible as the master, -# and to allow or deny to store the data. -# -# Allow this node to be eligible as a master node (enabled by default): -# -{{ macros.config_row(config, 'node.master', '#node.master: true', 0, true) }} -# -# Allow this node to store data (enabled by default): -# -{{ macros.config_row(config, 'node.data', '#node.data: true', 0, true) }} - -# You can exploit these settings to design advanced cluster topologies. -# -# 1. You want this node to never become a master node, only to hold data. -# This will be the "workhorse" of your cluster. -# -#node.master: false -#node.data: true -# -# 2. You want this node to only serve as a master: to not store any data and -# to have free resources. This will be the "coordinator" of your cluster. -# -#node.master: true -#node.data: false -# -# 3. You want this node to be neither master nor data node, but -# to act as a "search load balancer" (fetching data from nodes, -# aggregating results, etc.) -# -#node.master: false -#node.data: false - -# Use the Cluster Health API [http://localhost:9200/_cluster/health], the -# Node Info API [http://localhost:9200/_nodes] or GUI tools -# such as , -# , -# and -# to inspect the cluster state. - -# A node can have generic attributes associated with it, which can later be used -# for customized shard allocation filtering, or allocation awareness. An attribute -# is a simple key value pair, similar to node.key: value, here is an example: -# -#node.rack: rack314 - -# By default, multiple nodes are allowed to start from the same installation location -# to disable it, set the following: -{{ macros.config_row(config, 'node.max_local_storage_nodes', '#node.max_local_storage_nodes: 1', 0, true) }} - - -#################################### Index #################################### - -# You can set a number of options (such as shard/replica options, mapping -# or analyzer definitions, translog settings, ...) for indices globally, -# in this file. -# -# Note, that it makes more sense to configure index settings specifically for -# a certain index, either when creating it or by using the index templates API. -# -# See and -# -# for more information. - -# Set the number of shards (splits) of an index (5 by default): -# -{{ macros.config_row(config, 'index.number_of_shards', '#index.number_of_shards: 5', 0, true) }} - -# Set the number of replicas (additional copies) of an index (1 by default): -# -{{ macros.config_row(config, 'index.number_of_replicas', '#index.number_of_replicas: 1', 0, true) }} - -# Note, that for development on a local machine, with small indices, it usually -# makes sense to "disable" the distributed features: -# -#index.number_of_shards: 1 -#index.number_of_replicas: 0 - -# These settings directly affect the performance of index and search operations -# in your cluster. Assuming you have enough machines to hold shards and -# replicas, the rule of thumb is: -# -# 1. Having more *shards* enhances the _indexing_ performance and allows to -# _distribute_ a big index across machines. -# 2. Having more *replicas* enhances the _search_ performance and improves the -# cluster _availability_. -# -# The "number_of_shards" is a one-time setting for an index. -# -# The "number_of_replicas" can be increased or decreased anytime, -# by using the Index Update Settings API. -# -# Elasticsearch takes care about load balancing, relocating, gathering the -# results from nodes, etc. Experiment with different settings to fine-tune -# your setup. - -# Use the Index Status API () to inspect -# the index status. - - -#################################### Paths #################################### - -# Path to directory containing configuration (this file and logging.yml): -# -{{ macros.config_row(config, 'path.conf', '#path.conf: /path/to/conf', 0, true) }} - -# Path to directory where to store index data allocated for this node. -# -{{ macros.config_row(config, 'path.data', '#path.data: /path/to/data', 0, true) }} -# -# Can optionally include more than one location, causing data to be striped across -# the locations (a la RAID 0) on a file level, favouring locations with most free -# space on creation. For example: -# -#path.data: /path/to/data1,/path/to/data2 - -# Path to temporary files: -# -{{ macros.config_row(config, 'path.work', '#path.work: /path/to/work', 0, true) }} - -# Path to log files: -# -{{ macros.config_row(config, 'path.logs', '#path.logs: /path/to/logs', 0, true) }} - -# Path to where plugins are installed: -# -{{ macros.config_row(config, 'path.plugins', '#path.plugins: /path/to/plugins', 0, true) }} - - -#################################### Plugin ################################### - -# If a plugin listed here is not installed for current node, the node will not start. -# -{{ macros.config_row(config, 'plugin.mandatory', '#plugin.mandatory: mapper-attachments,lang-groovy', 0, true) }} - - -################################### Memory #################################### - -# Elasticsearch performs poorly when JVM starts swapping: you should ensure that -# it _never_ swaps. -# -# Set this property to true to lock the memory: -# -{{ macros.config_row(config, 'bootstrap.mlockall', '#bootstrap.mlockall: true', 0, true) }} - -# Make sure that the ES_MIN_MEM and ES_MAX_MEM environment variables are set -# to the same value, and that the machine has enough memory to allocate -# for Elasticsearch, leaving enough memory for the operating system itself. -# -# You should also make sure that the Elasticsearch process is allowed to lock -# the memory, eg. by using `ulimit -l unlimited`. - - -############################## Network And HTTP ############################### - -# Elasticsearch, by default, binds itself to the 0.0.0.0 address, and listens -# on port [9200-9300] for HTTP traffic and on port [9300-9400] for node-to-node -# communication. (the range means that if the port is busy, it will automatically -# try the next port). - -# Set the bind address specifically (IPv4 or IPv6): -# -{{ macros.config_row(config, 'network.bind_host', '#network.bind_host: 192.168.0.1', 0, true) }} - -# Set the address other nodes will use to communicate with this node. If not -# set, it is automatically derived. It must point to an actual IP address. -# -{{ macros.config_row(config, 'network.publish_host', '#network.publish_host: 192.168.0.1', 0, true) }} - -# Set both 'bind_host' and 'publish_host': -# -{{ macros.config_row(config, 'network.host', '#network.host: 192.168.0.1', 0, true) }} - -# Set a custom port for the node to node communication (9300 by default): -# -{{ macros.config_row(config, 'transport.tcp.port', '#transport.tcp.port: 9300', 0, true) }} - -# Enable compression for all communication between nodes (disabled by default): -# -{{ macros.config_row(config, 'transport.tcp.compress', '#transport.tcp.compress: true', 0, true) }} - -# Set a custom port to listen for HTTP traffic: -# -{{ macros.config_row(config, 'http.port', '#http.port: 9200', 0, true) }} - -# Set a custom allowed content length: -# -{{ macros.config_row(config, 'http.max_content_length', '#http.max_content_length: 100mb', 0, true) }} - -# Disable HTTP completely: -# -{{ macros.config_row(config, 'http.enabled', '#http.enabled: false', 0, true) }} - - -################################### Gateway ################################### - -# The gateway allows for persisting the cluster state between full cluster -# restarts. Every change to the state (such as adding an index) will be stored -# in the gateway, and when the cluster starts up for the first time, -# it will read its state from the gateway. - -# There are several types of gateway implementations. For more information, see -# . - -# The default gateway type is the "local" gateway (recommended): -# -{{ macros.config_row(config, 'gateway.type', '#gateway.type: local', 0, true) }} - -# Settings below control how and when to start the initial recovery process on -# a full cluster restart (to reuse as much local data as possible when using shared -# gateway). - -# Allow recovery process after N nodes in a cluster are up: -# -{{ macros.config_row(config, 'gateway.recover_after_nodes', '#gateway.recover_after_nodes: 1', 0, true) }} - -# Set the timeout to initiate the recovery process, once the N nodes -# from previous setting are up (accepts time value): -# -{{ macros.config_row(config, 'gateway.recover_after_time', '#gateway.recover_after_time: 5m', 0, true) }} - -# Set how many nodes are expected in this cluster. Once these N nodes -# are up (and recover_after_nodes is met), begin recovery process immediately -# (without waiting for recover_after_time to expire): -# -{{ macros.config_row(config, 'gateway.expected_nodes', '#gateway.expected_nodes: 2', 0, true) }} - - -############################# Recovery Throttling ############################# - -# These settings allow to control the process of shards allocation between -# nodes during initial recovery, replica allocation, rebalancing, -# or when adding and removing nodes. - -# Set the number of concurrent recoveries happening on a node: -# -# 1. During the initial recovery -# -{{ macros.config_row(config, 'cluster.routing.allocation.node_initial_primaries_recoveries', '#cluster.routing.allocation.node_initial_primaries_recoveries: 4', 0, true) }} -# -# 2. During adding/removing nodes, rebalancing, etc -# -{{ macros.config_row(config, 'cluster.routing.allocation.node_concurrent_recoveries', '#cluster.routing.allocation.node_concurrent_recoveries: 2', 0, true) }} - -# Set to throttle throughput when recovering (eg. 100mb, by default 20mb): -# -{{ macros.config_row(config, 'indices.recovery.max_bytes_per_sec', '#indices.recovery.max_bytes_per_sec: 20mb', 0, true) }} - -# Set to limit the number of open concurrent streams when -# recovering a shard from a peer: -# -{{ macros.config_row(config, 'indices.recovery.concurrent_streams', '#indices.recovery.concurrent_streams: 5', 0, true) }} - - -################################## Discovery ################################## - -# Discovery infrastructure ensures nodes can be found within a cluster -# and master node is elected. Multicast discovery is the default. - -# Set to ensure a node sees N other master eligible nodes to be considered -# operational within the cluster. This should be set to a quorum/majority of -# the master-eligible nodes in the cluster. -# -{{ macros.config_row(config, 'discovery.zen.minimum_master_nodes', '#discovery.zen.minimum_master_nodes: 1', 0, true) }} - -# Set the time to wait for ping responses from other nodes when discovering. -# Set this option to a higher value on a slow or congested network -# to minimize discovery failures: -# -{{ macros.config_row(config, 'discovery.zen.ping.timeout', '#discovery.zen.ping.timeout: 3s', 0, true) }} - -# For more information, see -# - -# Unicast discovery allows to explicitly control which nodes will be used -# to discover the cluster. It can be used when multicast is not present, -# or to restrict the cluster communication-wise. -# -# 1. Disable multicast discovery (enabled by default): -# -{{ macros.config_row(config, 'discovery.zen.ping.multicast.enabled', '#discovery.zen.ping.multicast.enabled: false', 0, true) }} -# -# 2. Configure an initial list of master nodes in the cluster -# to perform discovery when new nodes (master or data) are started: -# -{{ macros.config_row(config, 'discovery.zen.ping.unicast.hosts', '#discovery.zen.ping.unicast.hosts: ["host1", "host2:port"]', 0, true) }} - -# EC2 discovery allows to use AWS EC2 API in order to perform discovery. -# -# You have to install the cloud-aws plugin for enabling the EC2 discovery. -# -# For more information, see -# -# -# See -# for a step-by-step tutorial. - -# GCE discovery allows to use Google Compute Engine API in order to perform discovery. -# -# You have to install the cloud-gce plugin for enabling the GCE discovery. -# -# For more information, see . - -# Azure discovery allows to use Azure API in order to perform discovery. -# -# You have to install the cloud-azure plugin for enabling the Azure discovery. -# -# For more information, see . - -################################## Slow Log ################################## - -# Shard level query and fetch threshold logging. - -{{ macros.config_row(config, 'index.search.slowlog.threshold.query.warn', '#index.search.slowlog.threshold.query.warn: 10s', 0, true) }} -{{ macros.config_row(config, 'index.search.slowlog.threshold.query.info', '#index.search.slowlog.threshold.query.info: 5s', 0, true) }} -{{ macros.config_row(config, 'index.search.slowlog.threshold.query.debug', '#index.search.slowlog.threshold.query.debug: 2s', 0, true) }} -{{ macros.config_row(config, 'index.search.slowlog.threshold.query.trace', '#index.search.slowlog.threshold.query.trace: 500ms', 0, true) }} - -{{ macros.config_row(config, 'index.search.slowlog.threshold.fetch.warn', '#index.search.slowlog.threshold.fetch.warn: 1s', 0, true) }} -{{ macros.config_row(config, 'index.search.slowlog.threshold.fetch.info', '#index.search.slowlog.threshold.fetch.info: 800ms', 0, true) }} -{{ macros.config_row(config, 'index.search.slowlog.threshold.fetch.debug', '#index.search.slowlog.threshold.fetch.debug: 500ms', 0, true) }} -{{ macros.config_row(config, 'index.search.slowlog.threshold.fetch.trace', '#index.search.slowlog.threshold.fetch.trace: 200ms', 0, true) }} - -{{ macros.config_row(config, 'index.indexing.slowlog.threshold.index.warn', '#index.indexing.slowlog.threshold.index.warn: 10s', 0, true) }} -{{ macros.config_row(config, 'index.indexing.slowlog.threshold.index.info', '#index.indexing.slowlog.threshold.index.info: 5s', 0, true) }} -{{ macros.config_row(config, 'index.indexing.slowlog.threshold.index.debug', '#index.indexing.slowlog.threshold.index.debug: 2s', 0, true) }} -{{ macros.config_row(config, 'index.indexing.slowlog.threshold.index.trace', '#index.indexing.slowlog.threshold.index.trace: 500ms', 0, true) }} - -################################## GC Logging ################################ - -{{ macros.config_row(config, 'monitor.jvm.gc.young.warn', '#monitor.jvm.gc.young.warn: 1000ms', 0, true) }} -{{ macros.config_row(config, 'monitor.jvm.gc.young.info', '#monitor.jvm.gc.young.info: 700ms', 0, true) }} -{{ macros.config_row(config, 'monitor.jvm.gc.young.debug', '#monitor.jvm.gc.young.debug: 400ms', 0, true) }} - -{{ macros.config_row(config, 'monitor.jvm.gc.young.warn', '#monitor.jvm.gc.old.warn: 10s', 0, true) }} -{{ macros.config_row(config, 'monitor.jvm.gc.young.info', '#monitor.jvm.gc.old.info: 5s', 0, true) }} -{{ macros.config_row(config, 'monitor.jvm.gc.young.debug', '#monitor.jvm.gc.old.debug: 2s', 0, true) }} - -################################## Security ################################ - -# Uncomment if you want to enable JSONP as a valid return transport on the -# http server. With this enabled, it may pose a security risk, so disabling -# it unless you need it is recommended (it is disabled by default). -# -{{ macros.config_row(config, 'http.jsonp.enable', '#http.jsonp.enable: true', 0, true) }} - -{{ macros.config(config, [ - 'cluster.name', - 'node.name', - 'node.master', - 'node.data', - 'node.max_local_storage_nodes', - 'index.number_of_shards', - 'index.number_of_replicas', - 'path.conf', - 'path.data', - 'path.work', - 'path.logs', - 'path.plugins', - 'plugin.mandatory', - 'bootstrap.mlockall', - 'network.bind_host', - 'network.publish_host', - 'network.host', - 'transport.tcp.port', - 'transport.tcp.compress', - 'http.port', - 'http.max_content_length', - 'http.enabled', - 'gateway.type', - 'gateway.recover_after_nodes', - 'gateway.recover_after_time', - 'gateway.expected_nodes', - 'cluster.routing.allocation.node_initial_primaries_recoveries', - 'cluster.routing.allocation.node_concurrent_recoveries', - 'indices.recovery.max_bytes_per_sec', - 'indices.recovery.concurrent_streams', - 'discovery.zen.minimum_master_nodes', - 'discovery.zen.ping.timeout', - 'discovery.zen.ping.multicast.enabled', - 'discovery.zen.ping.unicast.hosts', - 'index.search.slowlog.threshold.query.warn', - 'index.search.slowlog.threshold.query.info', - 'index.search.slowlog.threshold.query.debug', - 'index.search.slowlog.threshold.query.trace', - 'index.search.slowlog.threshold.fetch.warn', - 'index.search.slowlog.threshold.fetch.info', - 'index.search.slowlog.threshold.fetch.debug', - 'index.search.slowlog.threshold.fetch.trace', - 'index.indexing.slowlog.threshold.index.warn', - 'index.indexing.slowlog.threshold.index.info', - 'index.indexing.slowlog.threshold.index.debug', - 'index.indexing.slowlog.threshold.index.trace', - 'monitor.jvm.gc.young.warn', - 'monitor.jvm.gc.young.info', - 'monitor.jvm.gc.young.debug', - 'monitor.jvm.gc.old.warn', - 'monitor.jvm.gc.old.info', - 'monitor.jvm.gc.old.debug', - 'http.jsonp.enable' -]) -}} diff --git a/roles/elasticsearch/templates/config/1.7/default.j2 b/roles/elasticsearch/templates/config/1.7/default.j2 deleted file mode 100644 index 4d1406767..000000000 --- a/roles/elasticsearch/templates/config/1.7/default.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include '1.7/_base.j2' %} diff --git a/roles/elasticsearch/templates/config/2/_base.j2 b/roles/elasticsearch/templates/config/2/_base.j2 deleted file mode 100755 index b735a329f..000000000 --- a/roles/elasticsearch/templates/config/2/_base.j2 +++ /dev/null @@ -1,116 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_elasticsearch_config -%} - -# ======================== Elasticsearch Configuration ========================= -# -# NOTE: Elasticsearch comes with reasonable defaults for most settings. -# Before you set out to tweak and tune the configuration, make sure you -# understand what are you trying to accomplish and the consequences. -# -# The primary way of configuring a node is via this file. This template lists -# the most important settings you may want to configure for a production cluster. -# -# Please see the documentation for further information on configuration options: -# -# -# ---------------------------------- Cluster ----------------------------------- -# -# Use a descriptive name for your cluster: -# -{{ macros.config_row(config, 'cluster.name', '# cluster.name: my-application', 0, true) }} -# -# ------------------------------------ Node ------------------------------------ -# -# Use a descriptive name for the node: -# -{{ macros.config_row(config, 'node.name', '# node.name: node-1', 0, true) }} -# -# Add custom attributes to the node: -# -{{ macros.config_row(config, 'node.rack', '# node.rack: r1', 0, true) }} -# -# ----------------------------------- Paths ------------------------------------ -# -# Path to directory where to store the data (separate multiple locations by comma): -# -{{ macros.config_row(config, 'path.data', '# path.data: /path/to/data', 0, true) }} -# -# Path to log files: -# -{{ macros.config_row(config, 'path.logs', '# path.logs: /path/to/logs', 0, true) }} -# -# ----------------------------------- Memory ----------------------------------- -# -# Lock the memory on startup: -# -{{ macros.config_row(config, 'bootstrap.memory_lock', '# bootstrap.memory_lock: true', 0, true) }} -# -# Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory -# available on the system and that the owner of the process is allowed to use this limit. -# -# Elasticsearch performs poorly when the system is swapping the memory. -# -# ---------------------------------- Network ----------------------------------- -# -# Set the bind address to a specific IP (IPv4 or IPv6): -# -{{ macros.config_row(config, 'network.host', '# network.host: 192.168.0.1', 0, true) }} -# -# Set a custom port for HTTP: -# -{{ macros.config_row(config, 'http.port', '# http.port: 9200', 0, true) }} -# -# For more information, see the documentation at: -# -# -# --------------------------------- Discovery ---------------------------------- -# -# Pass an initial list of hosts to perform discovery when new node is started: -# The default list of hosts is ["127.0.0.1", "[::1]"] -# -{{ macros.config_row(config, 'discovery.zen.ping.unicast.hosts', '# discovery.zen.ping.unicast.hosts: ["host1", "host2"]', 0, true) }} -# -# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1): -# -{{ macros.config_row(config, 'discovery.zen.minimum_master_nodes', '# discovery.zen.minimum_master_nodes: 3', 0, true) }} -# -# For more information, see the documentation at: -# -# -# ---------------------------------- Gateway ----------------------------------- -# -# Block initial recovery after a full cluster restart until N nodes are started: -# -{{ macros.config_row(config, 'gateway.recover_after_nodes', '# gateway.recover_after_nodes: 3', 0, true) }} -# -# For more information, see the documentation at: -# -# -# ---------------------------------- Various ----------------------------------- -# -# Disable starting multiple nodes on a single system: -# -{{ macros.config_row(config, 'node.max_local_storage_nodes', '# node.max_local_storage_nodes: 1', 0, true) }} -# -# Require explicit names when deleting indices: -# -{{ macros.config_row(config, 'action.destructive_requires_name', '# action.destructive_requires_name: true', 0, true) }} - -{{ macros.config(config, [ - 'cluster.name', - 'node.name', - 'node.rack', - 'path.data', - 'path.logs', - 'bootstrap.memory_lock', - 'network.host', - 'http.port', - 'discovery.zen.ping.unicast.hosts', - 'discovery.zen.minimum_master_nodes', - 'gateway.recover_after_nodes', - 'node.max_local_storage_nodes', - 'action.destructive_requires_name' -]) -}} diff --git a/roles/elasticsearch/templates/config/2/default.j2 b/roles/elasticsearch/templates/config/2/default.j2 deleted file mode 100644 index f94a160e1..000000000 --- a/roles/elasticsearch/templates/config/2/default.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include '2/_base.j2' %} diff --git a/roles/elasticsearch/templates/config/5/_base.j2 b/roles/elasticsearch/templates/config/5/_base.j2 deleted file mode 100644 index 312ea1e01..000000000 --- a/roles/elasticsearch/templates/config/5/_base.j2 +++ /dev/null @@ -1,109 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_elasticsearch_config -%} - -# ======================== Elasticsearch Configuration ========================= -# -# NOTE: Elasticsearch comes with reasonable defaults for most settings. -# Before you set out to tweak and tune the configuration, make sure you -# understand what are you trying to accomplish and the consequences. -# -# The primary way of configuring a node is via this file. This template lists -# the most important settings you may want to configure for a production cluster. -# -# Please consult the documentation for further information on configuration options: -# https://www.elastic.co/guide/en/elasticsearch/reference/index.html -# -# ---------------------------------- Cluster ----------------------------------- -# -# Use a descriptive name for your cluster: -# -{{ macros.config_row(config, 'cluster.name', '#cluster.name: my-application', 0, true) }} -# -# ------------------------------------ Node ------------------------------------ -# -# Use a descriptive name for the node: -# -{{ macros.config_row(config, 'node.name', '#node.name: node-1', 0, true) }} -# -# Add custom attributes to the node: -# -{{ macros.config_row(config, 'node.attr.rack', '#node.attr.rack: r1', 0, true) }} -# -# ----------------------------------- Paths ------------------------------------ -# -# Path to directory where to store the data (separate multiple locations by comma): -# -{{ macros.config_row(config, 'path.data', '#path.data: /path/to/data', 0, true) }} -# -# Path to log files: -# -{{ macros.config_row(config, 'path.logs', '#path.logs: /path/to/logs', 0, true) }} -# -# ----------------------------------- Memory ----------------------------------- -# -# Lock the memory on startup: -# -{{ macros.config_row(config, 'bootstrap.memory_lock', '#bootstrap.memory_lock: true', 0, true) }} -# -# Make sure that the heap size is set to about half the memory available -# on the system and that the owner of the process is allowed to use this -# limit. -# -# Elasticsearch performs poorly when the system is swapping the memory. -# -# ---------------------------------- Network ----------------------------------- -# -# Set the bind address to a specific IP (IPv4 or IPv6): -# -{{ macros.config_row(config, 'network.host', '#network.host: 192.168.0.1', 0, true) }} -# -# Set a custom port for HTTP: -# -{{ macros.config_row(config, 'http.port', '#http.port: 9200', 0, true) }} -# -# For more information, consult the network module documentation. -# -# --------------------------------- Discovery ---------------------------------- -# -# Pass an initial list of hosts to perform discovery when new node is started: -# The default list of hosts is ["127.0.0.1", "[::1]"] -# -{{ macros.config_row(config, 'discovery.zen.ping.unicast.hosts', '#discovery.zen.ping.unicast.hosts: ["host1", "host2"]', 0, true) }} -# -# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1): -# -{{ macros.config_row(config, 'discovery.zen.minimum_master_nodes', '#discovery.zen.minimum_master_nodes: 3', 0, true) }} -# -# For more information, consult the zen discovery module documentation. -# -# ---------------------------------- Gateway ----------------------------------- -# -# Block initial recovery after a full cluster restart until N nodes are started: -# -{{ macros.config_row(config, 'gateway.recover_after_nodes', '#gateway.recover_after_nodes: 3', 0, true) }} -# -# For more information, consult the gateway module documentation. -# -# ---------------------------------- Various ----------------------------------- -# -# Require explicit names when deleting indices: -# -{{ macros.config_row(config, 'action.destructive_requires_name', '#action.destructive_requires_name: true', 0, true) }} - -{{ macros.config(config, [ - 'cluster.name', - 'node.name', - 'node.attr.rack', - 'path.data', - 'path.logs', - 'bootstrap.memory_lock', - 'network.host', - 'http.port', - 'discovery.zen.ping.unicast.hosts', - 'discovery.zen.minimum_master_nodes', - 'gateway.recover_after_nodes', - 'action.destructive_requires_name' -]) -}} diff --git a/roles/elasticsearch/templates/config/5/default.j2 b/roles/elasticsearch/templates/config/5/default.j2 deleted file mode 100644 index e0d6a5a78..000000000 --- a/roles/elasticsearch/templates/config/5/default.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include '5/_base.j2' %} diff --git a/roles/elasticsearch/templates/config/6/_base.j2 b/roles/elasticsearch/templates/config/6/_base.j2 deleted file mode 100644 index d971455a8..000000000 --- a/roles/elasticsearch/templates/config/6/_base.j2 +++ /dev/null @@ -1,109 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_elasticsearch_config -%} - -# ======================== Elasticsearch Configuration ========================= -# -# NOTE: Elasticsearch comes with reasonable defaults for most settings. -# Before you set out to tweak and tune the configuration, make sure you -# understand what are you trying to accomplish and the consequences. -# -# The primary way of configuring a node is via this file. This template lists -# the most important settings you may want to configure for a production cluster. -# -# Please consult the documentation for further information on configuration options: -# https://www.elastic.co/guide/en/elasticsearch/reference/index.html -# -# ---------------------------------- Cluster ----------------------------------- -# -# Use a descriptive name for your cluster: -# -{{ macros.config_row(config, 'cluster.name', '#cluster.name: my-application', 0, true) }} -# -# ------------------------------------ Node ------------------------------------ -# -# Use a descriptive name for the node: -# -{{ macros.config_row(config, 'node.name', '#node.name: node-1', 0, true) }} -# -# Add custom attributes to the node: -# -{{ macros.config_row(config, 'node.attr.rack', '#node.attr.rack: r1', 0, true) }} -# -# ----------------------------------- Paths ------------------------------------ -# -# Path to directory where to store the data (separate multiple locations by comma): -# -{{ macros.config_row(config, 'path.data', '/var/lib/elasticsearch') }} -# -# Path to log files: -# -{{ macros.config_row(config, 'path.logs', '/var/log/elasticsearch') }} -# -# ----------------------------------- Memory ----------------------------------- -# -# Lock the memory on startup: -# -{{ macros.config_row(config, 'bootstrap.memory_lock', '#bootstrap.memory_lock: true', 0, true) }} -# -# Make sure that the heap size is set to about half the memory available -# on the system and that the owner of the process is allowed to use this -# limit. -# -# Elasticsearch performs poorly when the system is swapping the memory. -# -# ---------------------------------- Network ----------------------------------- -# -# Set the bind address to a specific IP (IPv4 or IPv6): -# -{{ macros.config_row(config, 'network.host', '#network.host: 192.168.0.1', 0, true) }} -# -# Set a custom port for HTTP: -# -{{ macros.config_row(config, 'http.port', '#http.port: 9200', 0, true) }} -# -# For more information, consult the network module documentation. -# -# --------------------------------- Discovery ---------------------------------- -# -# Pass an initial list of hosts to perform discovery when new node is started: -# The default list of hosts is ["127.0.0.1", "[::1]"] -# -{{ macros.config_row(config, 'discovery.zen.ping.unicast.hosts', '#discovery.zen.ping.unicast.hosts: ["host1", "host2"]', 0, true) }} -# -# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1): -# -{{ macros.config_row(config, 'discovery.zen.minimum_master_nodes', '#discovery.zen.minimum_master_nodes: ', 0, true) }} -# -# For more information, consult the zen discovery module documentation. -# -# ---------------------------------- Gateway ----------------------------------- -# -# Block initial recovery after a full cluster restart until N nodes are started: -# -{{ macros.config_row(config, 'gateway.recover_after_nodes', '#gateway.recover_after_nodes: 3', 0, true) }} -# -# For more information, consult the gateway module documentation. -# -# ---------------------------------- Various ----------------------------------- -# -# Require explicit names when deleting indices: -# -{{ macros.config_row(config, 'action.destructive_requires_name', '#action.destructive_requires_name: true', 0, true) }} - -{{ macros.config(config, [ - 'cluster.name', - 'node.name', - 'node.attr.rack', - 'path.data', - 'path.logs', - 'bootstrap.memory_lock', - 'network.host', - 'http.port', - 'discovery.zen.ping.unicast.hosts', - 'discovery.zen.minimum_master_nodes', - 'gateway.recover_after_nodes', - 'action.destructive_requires_name' -]) -}} diff --git a/roles/elasticsearch/templates/config/6/default.j2 b/roles/elasticsearch/templates/config/6/default.j2 deleted file mode 100644 index 04731e145..000000000 --- a/roles/elasticsearch/templates/config/6/default.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include '6/_base.j2' %} diff --git a/roles/elasticsearch/templates/config/7/_base.j2 b/roles/elasticsearch/templates/config/7/_base.j2 deleted file mode 100644 index d50d0453d..000000000 --- a/roles/elasticsearch/templates/config/7/_base.j2 +++ /dev/null @@ -1,109 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_elasticsearch_config -%} - -# ======================== Elasticsearch Configuration ========================= -# -# NOTE: Elasticsearch comes with reasonable defaults for most settings. -# Before you set out to tweak and tune the configuration, make sure you -# understand what are you trying to accomplish and the consequences. -# -# The primary way of configuring a node is via this file. This template lists -# the most important settings you may want to configure for a production cluster. -# -# Please consult the documentation for further information on configuration options: -# https://www.elastic.co/guide/en/elasticsearch/reference/index.html -# -# ---------------------------------- Cluster ----------------------------------- -# -# Use a descriptive name for your cluster: -# -{{ macros.config_row(config, 'cluster.name', '#cluster.name: my-application', 0, true) }} -# -# ------------------------------------ Node ------------------------------------ -# -# Use a descriptive name for the node: -# -{{ macros.config_row(config, 'node.name', '#node.name: node-1', 0, true) }} -# -# Add custom attributes to the node: -# -{{ macros.config_row(config, 'node.attr.rack', '#node.attr.rack: r1', 0, true) }} -# -# ----------------------------------- Paths ------------------------------------ -# -# Path to directory where to store the data (separate multiple locations by comma): -# -{{ macros.config_row(config, 'path.data', '/var/lib/elasticsearch') }} -# -# Path to log files: -# -{{ macros.config_row(config, 'path.logs', '/var/log/elasticsearch') }} -# -# ----------------------------------- Memory ----------------------------------- -# -# Lock the memory on startup: -# -{{ macros.config_row(config, 'bootstrap.memory_lock', '#bootstrap.memory_lock: true', 0, true) }} -# -# Make sure that the heap size is set to about half the memory available -# on the system and that the owner of the process is allowed to use this -# limit. -# -# Elasticsearch performs poorly when the system is swapping the memory. -# -# ---------------------------------- Network ----------------------------------- -# -# Set the bind address to a specific IP (IPv4 or IPv6): -# -{{ macros.config_row(config, 'network.host', '#network.host: 192.168.0.1', 0, true) }} -# -# Set a custom port for HTTP: -# -{{ macros.config_row(config, 'http.port', '#http.port: 9200', 0, true) }} -# -# For more information, consult the network module documentation. -# -# --------------------------------- Discovery ---------------------------------- -# -# Pass an initial list of hosts to perform discovery when this node is started: -# The default list of hosts is ["127.0.0.1", "[::1]"] -# -{{ macros.config_row(config, 'discovery.seed_hosts', '#discovery.seed_hosts: ["host1", "host2"]', 0, true) }} -# -# Bootstrap the cluster using an initial set of master-eligible nodes: -# -{{ macros.config_row(config, 'cluster.initial_master_nodes', '#cluster.initial_master_nodes: ["node-1", "node-2"]', 0, true) }} -# -# For more information, consult the discovery and cluster formation module documentation. -# -# ---------------------------------- Gateway ----------------------------------- -# -# Block initial recovery after a full cluster restart until N nodes are started: -# -{{ macros.config_row(config, 'gateway.recover_after_nodes', '#gateway.recover_after_nodes: 3', 0, true) }} -# -# For more information, consult the gateway module documentation. -# -# ---------------------------------- Various ----------------------------------- -# -# Require explicit names when deleting indices: -# -{{ macros.config_row(config, 'action.destructive_requires_name', '#action.destructive_requires_name: true', 0, true) }} - -{{ macros.config(config, [ - 'cluster.name', - 'node.name', - 'node.attr.rack', - 'path.data', - 'path.logs', - 'bootstrap.memory_lock', - 'network.host', - 'http.port', - 'discovery.seed_hosts', - 'cluster.initial_master_nodes', - 'gateway.recover_after_nodes', - 'action.destructive_requires_name' -]) -}} diff --git a/roles/elasticsearch/templates/config/7/default.j2 b/roles/elasticsearch/templates/config/7/default.j2 deleted file mode 100644 index 55c2acf0e..000000000 --- a/roles/elasticsearch/templates/config/7/default.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include '7/_base.j2' %} diff --git a/roles/elasticsearch/templates/config/_base.j2 b/roles/elasticsearch/templates/config/_base.j2 deleted file mode 100644 index 89a7fc51c..000000000 --- a/roles/elasticsearch/templates/config/_base.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{%- include manala_elasticsearch_version|string ~ '/default.j2' -%} diff --git a/roles/elasticsearch/templates/config/_default.j2 b/roles/elasticsearch/templates/config/_default.j2 index bfd1a6662..99d422b8d 100644 --- a/roles/elasticsearch/templates/config/_default.j2 +++ b/roles/elasticsearch/templates/config/_default.j2 @@ -2,12 +2,7 @@ {%- if config is mapping -%} -{{ config | manala_yaml }} - -{%- elif config is iterable and config is not string -%} - -{#- Deprecated -#} -{%- include '_base.j2' -%} +{{ config | manala.roles.yaml }} {%- else -%} diff --git a/roles/elasticsearch/templates/config/_macros.j2 b/roles/elasticsearch/templates/config/_macros.j2 deleted file mode 100644 index f89b1e608..000000000 --- a/roles/elasticsearch/templates/config/_macros.j2 +++ /dev/null @@ -1,68 +0,0 @@ -{#- Deprecated -#} - -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }}{{ '\n' }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {%- if value is sequence and value is not string -%} - {{ key|indent(indent, true) }}:{{ '\n' }}{{ config(value, [], 2 + indent) }} - {%- else -%} - {{ _config_parameter_key(key)|indent(indent, true) }}: {{ _config_parameter_value(value) }} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - {{ key }} -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {%- if value is sameas none -%} - {%- elif value is sameas true -%} - true - {%- elif value is sameas false -%} - false - {%- elif value is string -%} - {{ value }} - {%- elif value is number -%} - {{ value }} - {%- else -%} - {{ value }} - {%- endif -%} -{%- endmacro -%} diff --git a/roles/elasticsearch/templates/config/elasticsearch/1.7/elasticsearch.yml.j2 b/roles/elasticsearch/templates/config/elasticsearch/1.7/elasticsearch.yml.j2 deleted file mode 100644 index 685bdfc1f..000000000 --- a/roles/elasticsearch/templates/config/elasticsearch/1.7/elasticsearch.yml.j2 +++ /dev/null @@ -1,436 +0,0 @@ -{%- set config = manala_elasticsearch_config|default({}, true)|manala_yaml_flatten -%} - -##################### Elasticsearch Configuration Example ##################### - -# This file contains an overview of various configuration settings, -# targeted at operations staff. Application developers should -# consult the guide at . -# -# The installation procedure is covered at -# . -# -# Elasticsearch comes with reasonable defaults for most settings, -# so you can try it out without bothering with configuration. -# -# Most of the time, these defaults are just fine for running a production -# cluster. If you're fine-tuning your cluster, or wondering about the -# effect of certain configuration option, please _do ask_ on the -# mailing list or IRC channel [http://elasticsearch.org/community]. - -# Any element in the configuration can be replaced with environment variables -# by placing them in ${...} notation. For example: -# -#node.rack: ${RACK_ENV_VAR} - -# For information on supported formats and syntax for the config file, see -# - - -################################### Cluster ################################### - -# Cluster name identifies your cluster for auto-discovery. If you're running -# multiple clusters on the same network, make sure you're using unique names. -# -{{ config | manala_yaml_parameter('cluster.name', default='elasticsearch', comment=True) }} - - -#################################### Node ##################################### - -# Node names are generated dynamically on startup, so you're relieved -# from configuring them manually. You can tie this node to a specific name: -# -{{ config | manala_yaml_parameter('node.name', comment='#node.name: "Franz Kafka"') }} - -# Every node can be configured to allow or deny being eligible as the master, -# and to allow or deny to store the data. -# -# Allow this node to be eligible as a master node (enabled by default): -# -{{ config | manala_yaml_parameter('node.master', default=True, comment=True) }} -# -# Allow this node to store data (enabled by default): -# -{{ config | manala_yaml_parameter('node.data', default=True, comment=True) }} - -# You can exploit these settings to design advanced cluster topologies. -# -# 1. You want this node to never become a master node, only to hold data. -# This will be the "workhorse" of your cluster. -# -#node.master: false -#node.data: true -# -# 2. You want this node to only serve as a master: to not store any data and -# to have free resources. This will be the "coordinator" of your cluster. -# -#node.master: true -#node.data: false -# -# 3. You want this node to be neither master nor data node, but -# to act as a "search load balancer" (fetching data from nodes, -# aggregating results, etc.) -# -#node.master: false -#node.data: false - -# Use the Cluster Health API [http://localhost:9200/_cluster/health], the -# Node Info API [http://localhost:9200/_nodes] or GUI tools -# such as , -# , -# and -# to inspect the cluster state. - -# A node can have generic attributes associated with it, which can later be used -# for customized shard allocation filtering, or allocation awareness. An attribute -# is a simple key value pair, similar to node.key: value, here is an example: -# -#node.rack: rack314 - -# By default, multiple nodes are allowed to start from the same installation location -# to disable it, set the following: -{{ config | manala_yaml_parameter('node.max_local_storage_nodes', default=1, comment=True) }} - - -#################################### Index #################################### - -# You can set a number of options (such as shard/replica options, mapping -# or analyzer definitions, translog settings, ...) for indices globally, -# in this file. -# -# Note, that it makes more sense to configure index settings specifically for -# a certain index, either when creating it or by using the index templates API. -# -# See and -# -# for more information. - -# Set the number of shards (splits) of an index (5 by default): -# -{{ config | manala_yaml_parameter('index.number_of_shards', default=5, comment=True) }} - -# Set the number of replicas (additional copies) of an index (1 by default): -# -{{ config | manala_yaml_parameter('index.number_of_replicas', default=1, comment=True) }} - -# Note, that for development on a local machine, with small indices, it usually -# makes sense to "disable" the distributed features: -# -#index.number_of_shards: 1 -#index.number_of_replicas: 0 - -# These settings directly affect the performance of index and search operations -# in your cluster. Assuming you have enough machines to hold shards and -# replicas, the rule of thumb is: -# -# 1. Having more *shards* enhances the _indexing_ performance and allows to -# _distribute_ a big index across machines. -# 2. Having more *replicas* enhances the _search_ performance and improves the -# cluster _availability_. -# -# The "number_of_shards" is a one-time setting for an index. -# -# The "number_of_replicas" can be increased or decreased anytime, -# by using the Index Update Settings API. -# -# Elasticsearch takes care about load balancing, relocating, gathering the -# results from nodes, etc. Experiment with different settings to fine-tune -# your setup. - -# Use the Index Status API () to inspect -# the index status. - - -#################################### Paths #################################### - -# Path to directory containing configuration (this file and logging.yml): -# -{{ config | manala_yaml_parameter('path.conf', default='/path/to/conf', comment=True) }} - -# Path to directory where to store index data allocated for this node. -# -{{ config | manala_yaml_parameter('path.data', default='/path/to/data', comment=True) }} -# -# Can optionally include more than one location, causing data to be striped across -# the locations (a la RAID 0) on a file level, favouring locations with most free -# space on creation. For example: -# -#path.data: /path/to/data1,/path/to/data2 - -# Path to temporary files: -# -{{ config | manala_yaml_parameter('path.work', default='/path/to/work', comment=True) }} - -# Path to log files: -# -{{ config | manala_yaml_parameter('path.logs', default='/path/to/logs', comment=True) }} - -# Path to where plugins are installed: -# -{{ config | manala_yaml_parameter('path.plugins', default='/path/to/plugins', comment=True) }} - - -#################################### Plugin ################################### - -# If a plugin listed here is not installed for current node, the node will not start. -# -{{ config | manala_yaml_parameter('plugin.mandatory', default='mapper-attachments,lang-groovy', comment=True) }} - - -################################### Memory #################################### - -# Elasticsearch performs poorly when JVM starts swapping: you should ensure that -# it _never_ swaps. -# -# Set this property to true to lock the memory: -# -{{ config | manala_yaml_parameter('bootstrap.mlockall', default=True, comment=True) }} - -# Make sure that the ES_MIN_MEM and ES_MAX_MEM environment variables are set -# to the same value, and that the machine has enough memory to allocate -# for Elasticsearch, leaving enough memory for the operating system itself. -# -# You should also make sure that the Elasticsearch process is allowed to lock -# the memory, eg. by using `ulimit -l unlimited`. - - -############################## Network And HTTP ############################### - -# Elasticsearch, by default, binds itself to the 0.0.0.0 address, and listens -# on port [9200-9300] for HTTP traffic and on port [9300-9400] for node-to-node -# communication. (the range means that if the port is busy, it will automatically -# try the next port). - -# Set the bind address specifically (IPv4 or IPv6): -# -{{ config | manala_yaml_parameter('network.bind_host', default='192.168.0.1', comment=True) }} - -# Set the address other nodes will use to communicate with this node. If not -# set, it is automatically derived. It must point to an actual IP address. -# -{{ config | manala_yaml_parameter('network.publish_host', default='192.168.0.1', comment=True) }} - -# Set both 'bind_host' and 'publish_host': -# -{{ config | manala_yaml_parameter('network.host', default='192.168.0.1', comment=True) }} - -# Set a custom port for the node to node communication (9300 by default): -# -{{ config | manala_yaml_parameter('transport.tcp.port', default=9300, comment=True) }} - -# Enable compression for all communication between nodes (disabled by default): -# -{{ config | manala_yaml_parameter('transport.tcp.compress', default=True, comment=True) }} - -# Set a custom port to listen for HTTP traffic: -# -{{ config | manala_yaml_parameter('http.port', default=9200, comment=True) }} - -# Set a custom allowed content length: -# -{{ config | manala_yaml_parameter('http.max_content_length', default='100mb', comment=True) }} - -# Disable HTTP completely: -# -{{ config | manala_yaml_parameter('http.enabled', default=False, comment=True) }} - - -################################### Gateway ################################### - -# The gateway allows for persisting the cluster state between full cluster -# restarts. Every change to the state (such as adding an index) will be stored -# in the gateway, and when the cluster starts up for the first time, -# it will read its state from the gateway. - -# There are several types of gateway implementations. For more information, see -# . - -# The default gateway type is the "local" gateway (recommended): -# -{{ config | manala_yaml_parameter('gateway.type', default='local', comment=True) }} - -# Settings below control how and when to start the initial recovery process on -# a full cluster restart (to reuse as much local data as possible when using shared -# gateway). - -# Allow recovery process after N nodes in a cluster are up: -# -{{ config | manala_yaml_parameter('gateway.recover_after_nodes', default=1, comment=True) }} - -# Set the timeout to initiate the recovery process, once the N nodes -# from previous setting are up (accepts time value): -# -{{ config | manala_yaml_parameter('gateway.recover_after_time', default='5m', comment=True) }} - -# Set how many nodes are expected in this cluster. Once these N nodes -# are up (and recover_after_nodes is met), begin recovery process immediately -# (without waiting for recover_after_time to expire): -# -{{ config | manala_yaml_parameter('gateway.expected_nodes', default=2, comment=True) }} - - -############################# Recovery Throttling ############################# - -# These settings allow to control the process of shards allocation between -# nodes during initial recovery, replica allocation, rebalancing, -# or when adding and removing nodes. - -# Set the number of concurrent recoveries happening on a node: -# -# 1. During the initial recovery -# -{{ config | manala_yaml_parameter('cluster.routing.allocation.node_initial_primaries_recoveries', default=4, comment=True) }} -# -# 2. During adding/removing nodes, rebalancing, etc -# -{{ config | manala_yaml_parameter('cluster.routing.allocation.node_concurrent_recoveries', default=2, comment=True) }} - -# Set to throttle throughput when recovering (eg. 100mb, by default 20mb): -# -{{ config | manala_yaml_parameter('indices.recovery.max_bytes_per_sec', default='20mb', comment=True) }} - -# Set to limit the number of open concurrent streams when -# recovering a shard from a peer: -# -{{ config | manala_yaml_parameter('indices.recovery.concurrent_streams', default=5, comment=True) }} - - -################################## Discovery ################################## - -# Discovery infrastructure ensures nodes can be found within a cluster -# and master node is elected. Multicast discovery is the default. - -# Set to ensure a node sees N other master eligible nodes to be considered -# operational within the cluster. This should be set to a quorum/majority of -# the master-eligible nodes in the cluster. -# -{{ config | manala_yaml_parameter('discovery.zen.minimum_master_nodes', default=1, comment=True) }} - -# Set the time to wait for ping responses from other nodes when discovering. -# Set this option to a higher value on a slow or congested network -# to minimize discovery failures: -# -{{ config | manala_yaml_parameter('discovery.zen.ping.timeout', default='3s', comment=True) }} - -# For more information, see -# - -# Unicast discovery allows to explicitly control which nodes will be used -# to discover the cluster. It can be used when multicast is not present, -# or to restrict the cluster communication-wise. -# -# 1. Disable multicast discovery (enabled by default): -# -{{ config | manala_yaml_parameter('discovery.zen.ping.multicast.enabled', default=False, comment=True) }} -# -# 2. Configure an initial list of master nodes in the cluster -# to perform discovery when new nodes (master or data) are started: -# -{{ config | manala_yaml_parameter('discovery.zen.ping.unicast.hosts', comment='#discovery.zen.ping.unicast.hosts: ["host1", "host2:port"]') }} - -# EC2 discovery allows to use AWS EC2 API in order to perform discovery. -# -# You have to install the cloud-aws plugin for enabling the EC2 discovery. -# -# For more information, see -# -# -# See -# for a step-by-step tutorial. - -# GCE discovery allows to use Google Compute Engine API in order to perform discovery. -# -# You have to install the cloud-gce plugin for enabling the GCE discovery. -# -# For more information, see . - -# Azure discovery allows to use Azure API in order to perform discovery. -# -# You have to install the cloud-azure plugin for enabling the Azure discovery. -# -# For more information, see . - -################################## Slow Log ################################## - -# Shard level query and fetch threshold logging. - -{{ config | manala_yaml_parameter('index.search.slowlog.threshold.query.warn', default='10s', comment=True) }} -{{ config | manala_yaml_parameter('index.search.slowlog.threshold.query.info', default='5s', comment=True) }} -{{ config | manala_yaml_parameter('index.search.slowlog.threshold.query.debug', default='2s', comment=True) }} -{{ config | manala_yaml_parameter('index.search.slowlog.threshold.query.trace', default='500ms', comment=True) }} - -{{ config | manala_yaml_parameter('index.search.slowlog.threshold.fetch.warn', default='1s', comment=True) }} -{{ config | manala_yaml_parameter('index.search.slowlog.threshold.fetch.info', default='800ms', comment=True) }} -{{ config | manala_yaml_parameter('index.search.slowlog.threshold.fetch.debug', default='500ms', comment=True) }} -{{ config | manala_yaml_parameter('index.search.slowlog.threshold.fetch.trace', default='200ms', comment=True) }} - -{{ config | manala_yaml_parameter('index.indexing.slowlog.threshold.index.warn', default='10s', comment=True) }} -{{ config | manala_yaml_parameter('index.indexing.slowlog.threshold.index.info', default='5s', comment=True) }} -{{ config | manala_yaml_parameter('index.indexing.slowlog.threshold.index.debug', default='2s', comment=True) }} -{{ config | manala_yaml_parameter('index.indexing.slowlog.threshold.index.trace', default='500ms', comment=True) }} - -################################## GC Logging ################################ - -{{ config | manala_yaml_parameter('monitor.jvm.gc.young.warn', default='1000ms', comment=True) }} -{{ config | manala_yaml_parameter('monitor.jvm.gc.young.info', default='700ms', comment=True) }} -{{ config | manala_yaml_parameter('monitor.jvm.gc.young.debug', default='400ms', comment=True) }} - -{{ config | manala_yaml_parameter('monitor.jvm.gc.old.warn', default='10s', comment=True) }} -{{ config | manala_yaml_parameter('monitor.jvm.gc.old.info', default='5s', comment=True) }} -{{ config | manala_yaml_parameter('monitor.jvm.gc.old.debug', default='2s', comment=True) }} - -################################## Security ################################ - -# Uncomment if you want to enable JSONP as a valid return transport on the -# http server. With this enabled, it may pose a security risk, so disabling -# it unless you need it is recommended (it is disabled by default). -# -{{ config | manala_yaml_parameter('http.jsonp.enable', default=True, comment=True) }} - -{{ config | manala_yaml(exclude=[ - 'cluster.name', - 'node.name', - 'node.master', - 'node.data', - 'node.max_local_storage_nodes' - 'index.number_of_shards', - 'index.number_of_replicas', - 'path.conf', - 'path.data', - 'path.work', - 'path.logs', - 'path.plugins', - 'plugin.mandatory', - 'bootstrap.mlockall', - 'network.bind_host', - 'network.host', - 'transport.tcp.compress', - 'http.port', - 'http.max_content_length', - 'http.enabled', - 'gateway.type', - 'gateway.recover_after_nodes', - 'gateway.recover_after_time', - 'gateway.expected_nodes', - 'cluster.routing.allocation.node_initial_primaries_recoveries', - 'cluster.routing.allocation.node_concurrent_recoveries', - 'indices.recovery.max_bytes_per_sec', - 'indices.recovery.concurrent_streams', - 'discovery.zen.minimum_master_nodes', - 'discovery.zen.ping.timeout', - 'discovery.zen.ping.multicast.enabled', - 'index.search.slowlog.threshold.query.warn', - 'index.search.slowlog.threshold.query.info', - 'index.search.slowlog.threshold.query.debug', - 'index.search.slowlog.threshold.query.trace', - 'index.search.slowlog.threshold.fetch.warn', - 'index.search.slowlog.threshold.fetch.info', - 'index.search.slowlog.threshold.fetch.debug', - 'index.search.slowlog.threshold.fetch.trace', - 'monitor.jvm.gc.young.warn', - 'monitor.jvm.gc.young.info', - 'monitor.jvm.gc.young.debug', - 'monitor.jvm.gc.old.warn', - 'monitor.jvm.gc.old.info', - 'monitor.jvm.gc.old.debug', - 'http.jsonp.enable', -]) }} diff --git a/roles/elasticsearch/templates/config/elasticsearch/2/elasticsearch.yml.j2 b/roles/elasticsearch/templates/config/elasticsearch/2/elasticsearch.yml.j2 index eeaf26d6b..2b37606a4 100644 --- a/roles/elasticsearch/templates/config/elasticsearch/2/elasticsearch.yml.j2 +++ b/roles/elasticsearch/templates/config/elasticsearch/2/elasticsearch.yml.j2 @@ -1,4 +1,4 @@ -{%- set config = manala_elasticsearch_config|default({}, true)|manala_yaml_flatten -%} +{%- set config = manala_elasticsearch_config|default({}, true)|manala.roles.yaml_flatten -%} # ======================== Elasticsearch Configuration ========================= # @@ -16,13 +16,13 @@ # # Use a descriptive name for your cluster: # -{{ config | manala_yaml_parameter('cluster.name', comment='# cluster.name: my-application') }} +{{ config | manala.roles.yaml_parameter('cluster.name', comment='# cluster.name: my-application') }} # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # -{{ config | manala_yaml_parameter('node.name', comment='# node.name: node-1') }} +{{ config | manala.roles.yaml_parameter('node.name', comment='# node.name: node-1') }} # # Add custom attributes to the node: # @@ -32,17 +32,17 @@ # # Path to directory where to store the data (separate multiple locations by comma): # -{{ config | manala_yaml_parameter('path.data', comment='# path.data: /path/to/data') }} +{{ config | manala.roles.yaml_parameter('path.data', comment='# path.data: /path/to/data') }} # # Path to log files: # -{{ config | manala_yaml_parameter('path.logs', comment='# path.logs: /path/to/logs') }} +{{ config | manala.roles.yaml_parameter('path.logs', comment='# path.logs: /path/to/logs') }} # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # -{{ config | manala_yaml_parameter('bootstrap.memory_lock', comment='# bootstrap.memory_lock: true') }} +{{ config | manala.roles.yaml_parameter('bootstrap.memory_lock', comment='# bootstrap.memory_lock: true') }} # # Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory # available on the system and that the owner of the process is allowed to use this limit. @@ -53,11 +53,11 @@ # # Set the bind address to a specific IP (IPv4 or IPv6): # -{{ config | manala_yaml_parameter('network.host', comment='# network.host: 192.168.0.1') }} +{{ config | manala.roles.yaml_parameter('network.host', comment='# network.host: 192.168.0.1') }} # # Set a custom port for HTTP: # -{{ config | manala_yaml_parameter('http.port', comment='# http.port: 9200') }} +{{ config | manala.roles.yaml_parameter('http.port', comment='# http.port: 9200') }} # # For more information, see the documentation at: # @@ -67,11 +67,11 @@ # Pass an initial list of hosts to perform discovery when new node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # -{{ config | manala_yaml_parameter('discovery.zen.ping.unicast.hosts', comment='# discovery.zen.ping.unicast.hosts: ["host1", "host2"]') }} +{{ config | manala.roles.yaml_parameter('discovery.zen.ping.unicast.hosts', comment='# discovery.zen.ping.unicast.hosts: ["host1", "host2"]') }} # # Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1): # -{{ config | manala_yaml_parameter('discovery.zen.minimum_master_nodes', comment='# discovery.zen.minimum_master_nodes: 3') }} +{{ config | manala.roles.yaml_parameter('discovery.zen.minimum_master_nodes', comment='# discovery.zen.minimum_master_nodes: 3') }} # # For more information, see the documentation at: # @@ -80,7 +80,7 @@ # # Block initial recovery after a full cluster restart until N nodes are started: # -{{ config | manala_yaml_parameter('gateway.recover_after_nodes', comment='# gateway.recover_after_nodes: 3') }} +{{ config | manala.roles.yaml_parameter('gateway.recover_after_nodes', comment='# gateway.recover_after_nodes: 3') }} # # For more information, see the documentation at: # @@ -89,13 +89,13 @@ # # Disable starting multiple nodes on a single system: # -{{ config | manala_yaml_parameter('node.max_local_storage_nodes', comment='# node.max_local_storage_nodes: 1') }} +{{ config | manala.roles.yaml_parameter('node.max_local_storage_nodes', comment='# node.max_local_storage_nodes: 1') }} # # Require explicit names when deleting indices: # -{{ config | manala_yaml_parameter('action.destructive_requires_name', comment='# action.destructive_requires_name: true') }} +{{ config | manala.roles.yaml_parameter('action.destructive_requires_name', comment='# action.destructive_requires_name: true') }} -{{ config | manala_yaml(exclude=[ +{{ config | manala.roles.yaml(exclude=[ 'cluster.name', 'node.name', 'path.data', diff --git a/roles/elasticsearch/templates/config/elasticsearch/5/elasticsearch.yml.j2 b/roles/elasticsearch/templates/config/elasticsearch/5/elasticsearch.yml.j2 index 22edbb343..fd1535188 100644 --- a/roles/elasticsearch/templates/config/elasticsearch/5/elasticsearch.yml.j2 +++ b/roles/elasticsearch/templates/config/elasticsearch/5/elasticsearch.yml.j2 @@ -1,4 +1,4 @@ -{%- set config = manala_elasticsearch_config|default({}, true)|manala_yaml_flatten -%} +{%- set config = manala_elasticsearch_config|default({}, true)|manala.roles.yaml_flatten -%} # ======================== Elasticsearch Configuration ========================= # @@ -16,13 +16,13 @@ # # Use a descriptive name for your cluster: # -{{ config | manala_yaml_parameter('cluster.name', default='my-application', comment=True) }} +{{ config | manala.roles.yaml_parameter('cluster.name', default='my-application', comment=True) }} # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # -{{ config | manala_yaml_parameter('node.name', default='node-1', comment=True) }} +{{ config | manala.roles.yaml_parameter('node.name', default='node-1', comment=True) }} # # Add custom attributes to the node: # @@ -32,17 +32,17 @@ # # Path to directory where to store the data (separate multiple locations by comma): # -{{ config | manala_yaml_parameter('path.data', default='/path/to/data', comment=True) }} +{{ config | manala.roles.yaml_parameter('path.data', default='/path/to/data', comment=True) }} # # Path to log files: # -{{ config | manala_yaml_parameter('path.logs', default='/path/to/logs', comment=True) }} +{{ config | manala.roles.yaml_parameter('path.logs', default='/path/to/logs', comment=True) }} # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # -{{ config | manala_yaml_parameter('bootstrap.memory_lock', default=True, comment=True) }} +{{ config | manala.roles.yaml_parameter('bootstrap.memory_lock', default=True, comment=True) }} # # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this @@ -54,11 +54,11 @@ # # Set the bind address to a specific IP (IPv4 or IPv6): # -{{ config | manala_yaml_parameter('network.host', default='192.168.0.1', comment=True) }} +{{ config | manala.roles.yaml_parameter('network.host', default='192.168.0.1', comment=True) }} # # Set a custom port for HTTP: # -{{ config | manala_yaml_parameter('http.port', default=9200, comment=True) }} +{{ config | manala.roles.yaml_parameter('http.port', default=9200, comment=True) }} # # For more information, consult the network module documentation. # @@ -67,11 +67,11 @@ # Pass an initial list of hosts to perform discovery when new node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # -{{ config | manala_yaml_parameter('discovery.zen.ping.unicast.hosts', comment='#discovery.zen.ping.unicast.hosts: ["host1", "host2"]') }} +{{ config | manala.roles.yaml_parameter('discovery.zen.ping.unicast.hosts', comment='#discovery.zen.ping.unicast.hosts: ["host1", "host2"]') }} # # Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1): # -{{ config | manala_yaml_parameter('discovery.zen.minimum_master_nodes', comment='#discovery.zen.minimum_master_nodes: 3') }} +{{ config | manala.roles.yaml_parameter('discovery.zen.minimum_master_nodes', comment='#discovery.zen.minimum_master_nodes: 3') }} # # For more information, consult the zen discovery module documentation. # @@ -79,7 +79,7 @@ # # Block initial recovery after a full cluster restart until N nodes are started: # -{{ config | manala_yaml_parameter('gateway.recover_after_nodes', default=3, comment=True) }} +{{ config | manala.roles.yaml_parameter('gateway.recover_after_nodes', default=3, comment=True) }} # # For more information, consult the gateway module documentation. # @@ -87,9 +87,9 @@ # # Require explicit names when deleting indices: # -{{ config | manala_yaml_parameter('action.destructive_requires_name', default=True, comment=True) }} +{{ config | manala.roles.yaml_parameter('action.destructive_requires_name', default=True, comment=True) }} -{{ config | manala_yaml(exclude=[ +{{ config | manala.roles.yaml(exclude=[ 'cluster.name', 'node.name', 'path.data', diff --git a/roles/elasticsearch/templates/config/elasticsearch/6/elasticsearch.yml.j2 b/roles/elasticsearch/templates/config/elasticsearch/6/elasticsearch.yml.j2 index 4d37dfc7d..5764b466c 100644 --- a/roles/elasticsearch/templates/config/elasticsearch/6/elasticsearch.yml.j2 +++ b/roles/elasticsearch/templates/config/elasticsearch/6/elasticsearch.yml.j2 @@ -1,4 +1,4 @@ -{%- set config = manala_elasticsearch_config|default({}, true)|manala_yaml_flatten -%} +{%- set config = manala_elasticsearch_config|default({}, true)|manala.roles.yaml_flatten -%} # ======================== Elasticsearch Configuration ========================= # @@ -16,13 +16,13 @@ # # Use a descriptive name for your cluster: # -{{ config | manala_yaml_parameter('cluster.name', default='my-application', comment=True) }} +{{ config | manala.roles.yaml_parameter('cluster.name', default='my-application', comment=True) }} # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # -{{ config | manala_yaml_parameter('node.name', default='node-1', comment=True) }} +{{ config | manala.roles.yaml_parameter('node.name', default='node-1', comment=True) }} # # Add custom attributes to the node: # @@ -32,17 +32,17 @@ # # Path to directory where to store the data (separate multiple locations by comma): # -{{ config | manala_yaml_parameter('path.data', default='/var/lib/elasticsearch') }} +{{ config | manala.roles.yaml_parameter('path.data', default='/var/lib/elasticsearch') }} # # Path to log files: # -{{ config | manala_yaml_parameter('path.logs', default='/var/log/elasticsearch') }} +{{ config | manala.roles.yaml_parameter('path.logs', default='/var/log/elasticsearch') }} # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # -{{ config | manala_yaml_parameter('bootstrap.memory_lock', default=True, comment=True) }} +{{ config | manala.roles.yaml_parameter('bootstrap.memory_lock', default=True, comment=True) }} # # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this @@ -54,11 +54,11 @@ # # Set the bind address to a specific IP (IPv4 or IPv6): # -{{ config | manala_yaml_parameter('network.host', default='192.168.0.1', comment=True) }} +{{ config | manala.roles.yaml_parameter('network.host', default='192.168.0.1', comment=True) }} # # Set a custom port for HTTP: # -{{ config | manala_yaml_parameter('http.port', default=9200, comment=True) }} +{{ config | manala.roles.yaml_parameter('http.port', default=9200, comment=True) }} # # For more information, consult the network module documentation. # @@ -67,11 +67,11 @@ # Pass an initial list of hosts to perform discovery when new node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # -{{ config | manala_yaml_parameter('discovery.zen.ping.unicast.hosts', comment='#discovery.zen.ping.unicast.hosts: ["host1", "host2"]') }} +{{ config | manala.roles.yaml_parameter('discovery.zen.ping.unicast.hosts', comment='#discovery.zen.ping.unicast.hosts: ["host1", "host2"]') }} # # Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1): # -{{ config | manala_yaml_parameter('discovery.zen.minimum_master_nodes', comment='#discovery.zen.minimum_master_nodes: ') }} +{{ config | manala.roles.yaml_parameter('discovery.zen.minimum_master_nodes', comment='#discovery.zen.minimum_master_nodes: ') }} # # For more information, consult the zen discovery module documentation. # @@ -79,7 +79,7 @@ # # Block initial recovery after a full cluster restart until N nodes are started: # -{{ config | manala_yaml_parameter('gateway.recover_after_nodes', default=3, comment=True) }} +{{ config | manala.roles.yaml_parameter('gateway.recover_after_nodes', default=3, comment=True) }} # # For more information, consult the gateway module documentation. # @@ -87,9 +87,9 @@ # # Require explicit names when deleting indices: # -{{ config | manala_yaml_parameter('action.destructive_requires_name', default=True, comment=True) }} +{{ config | manala.roles.yaml_parameter('action.destructive_requires_name', default=True, comment=True) }} -{{ config | manala_yaml(exclude=[ +{{ config | manala.roles.yaml(exclude=[ 'cluster.name', 'node.name', 'path.data', diff --git a/roles/elasticsearch/templates/config/elasticsearch/7/elasticsearch.yml.j2 b/roles/elasticsearch/templates/config/elasticsearch/7/elasticsearch.yml.j2 index 22517ea32..c0a2ba8fe 100644 --- a/roles/elasticsearch/templates/config/elasticsearch/7/elasticsearch.yml.j2 +++ b/roles/elasticsearch/templates/config/elasticsearch/7/elasticsearch.yml.j2 @@ -1,4 +1,4 @@ -{%- set config = manala_elasticsearch_config|default({}, true)|manala_yaml_flatten -%} +{%- set config = manala_elasticsearch_config|default({}, true)|manala.roles.yaml_flatten -%} # ======================== Elasticsearch Configuration ========================= # @@ -16,13 +16,13 @@ # # Use a descriptive name for your cluster: # -{{ config | manala_yaml_parameter('cluster.name', default='my-application', comment=True) }} +{{ config | manala.roles.yaml_parameter('cluster.name', default='my-application', comment=True) }} # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # -{{ config | manala_yaml_parameter('node.name', default='node-1', comment=True) }} +{{ config | manala.roles.yaml_parameter('node.name', default='node-1', comment=True) }} # # Add custom attributes to the node: # @@ -32,17 +32,17 @@ # # Path to directory where to store the data (separate multiple locations by comma): # -{{ config | manala_yaml_parameter('path.data', default='/var/lib/elasticsearch') }} +{{ config | manala.roles.yaml_parameter('path.data', default='/var/lib/elasticsearch') }} # # Path to log files: # -{{ config | manala_yaml_parameter('path.logs', default='/var/log/elasticsearch') }} +{{ config | manala.roles.yaml_parameter('path.logs', default='/var/log/elasticsearch') }} # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # -{{ config | manala_yaml_parameter('bootstrap.memory_lock', default=True, comment=True) }} +{{ config | manala.roles.yaml_parameter('bootstrap.memory_lock', default=True, comment=True) }} # # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this @@ -54,11 +54,11 @@ # # Set the bind address to a specific IP (IPv4 or IPv6): # -{{ config | manala_yaml_parameter('network.host', default='192.168.0.1', comment=True) }} +{{ config | manala.roles.yaml_parameter('network.host', default='192.168.0.1', comment=True) }} # # Set a custom port for HTTP: # -{{ config | manala_yaml_parameter('http.port', default=9200, comment=True) }} +{{ config | manala.roles.yaml_parameter('http.port', default=9200, comment=True) }} # # For more information, consult the network module documentation. # @@ -67,11 +67,11 @@ # Pass an initial list of hosts to perform discovery when this node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # -{{ config | manala_yaml_parameter('discovery.seed_hosts', comment='#discovery.seed_hosts: ["host1", "host2"]') }} +{{ config | manala.roles.yaml_parameter('discovery.seed_hosts', comment='#discovery.seed_hosts: ["host1", "host2"]') }} # # Bootstrap the cluster using an initial set of master-eligible nodes: # -{{ config | manala_yaml_parameter('cluster.initial_master_nodes', comment='#cluster.initial_master_nodes: ["node-1", "node-2"]') }} +{{ config | manala.roles.yaml_parameter('cluster.initial_master_nodes', comment='#cluster.initial_master_nodes: ["node-1", "node-2"]') }} # # For more information, consult the discovery and cluster formation module documentation. # @@ -79,7 +79,7 @@ # # Block initial recovery after a full cluster restart until N nodes are started: # -{{ config | manala_yaml_parameter('gateway.recover_after_nodes', default=3, comment=True) }} +{{ config | manala.roles.yaml_parameter('gateway.recover_after_nodes', default=3, comment=True) }} # # For more information, consult the gateway module documentation. # @@ -87,9 +87,9 @@ # # Require explicit names when deleting indices: # -{{ config | manala_yaml_parameter('action.destructive_requires_name', default=True, comment=True) }} +{{ config | manala.roles.yaml_parameter('action.destructive_requires_name', default=True, comment=True) }} -{{ config | manala_yaml(exclude=[ +{{ config | manala.roles.yaml(exclude=[ 'cluster.name', 'node.name', 'path.data', diff --git a/roles/elasticsearch/templates/environment/1.7/_base.j2 b/roles/elasticsearch/templates/environment/1.7/_base.j2 deleted file mode 100644 index 312b489cd..000000000 --- a/roles/elasticsearch/templates/environment/1.7/_base.j2 +++ /dev/null @@ -1,105 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_elasticsearch_environment -%} - -################################ -# Elasticsearch -################################ - -# Elasticsearch home directory -{{ macros.config_row(config, 'ES_HOME', '#ES_HOME=/usr/share/elasticsearch', 0, true) }} - -# Elasticsearch configuration directory -{{ macros.config_row(config, 'CONF_DIR', '#CONF_DIR=/etc/elasticsearch', 0, true) }} - -# Elasticsearch configuration file -{{ macros.config_row(config, 'CONF_FILE', '#CONF_FILE=$CONF_DIR/elasticsearch.yml', 0, true) }} - -# Elasticsearch data directory -{{ macros.config_row(config, 'DATA_DIR', '#DATA_DIR=/var/lib/elasticsearch', 0, true) }} - -# Elasticsearch logs directory -{{ macros.config_row(config, 'LOG_DIR', '#LOG_DIR=/var/log/elasticsearch', 0, true) }} - -# Elasticsearch work directory -{{ macros.config_row(config, 'WORK_DIR', '#WORK_DIR=/tmp/elasticsearch', 0, true) }} - -# Elasticsearch PID directory -{{ macros.config_row(config, 'PID_DIR', '#PID_DIR=/var/run/elasticsearch', 0, true) }} - -# Heap size defaults to 256m min, 1g max -# Set ES_HEAP_SIZE to 50% of available RAM, but no more than 31g -{{ macros.config_row(config, 'ES_HEAP_SIZE', '#ES_HEAP_SIZE=2g', 0, true) }} - -# Heap new generation -{{ macros.config_row(config, 'ES_HEAP_NEWSIZE', '#ES_HEAP_NEWSIZE=', 0, true) }} - -# Maximum direct memory -{{ macros.config_row(config, 'ES_DIRECT_SIZE', '#ES_DIRECT_SIZE=', 0, true) }} - -# Additional Java OPTS -{{ macros.config_row(config, 'ES_JAVA_OPTS', '#ES_JAVA_OPTS=', 0, true) }} - -# Configure restart on package upgrade (true, every other setting will lead to not restarting) -{{ macros.config_row(config, 'ES_RESTART_ON_UPGRADE', '#ES_RESTART_ON_UPGRADE=true', 0, true) }} - -# Path to the GC log file -{{ macros.config_row(config, 'ES_GC_LOG_FILE', '#ES_GC_LOG_FILE=/var/log/elasticsearch/gc.log', 0, true) }} - -################################ -# Elasticsearch service -################################ - -# SysV init.d -# -# When executing the init script, this user will be used to run the elasticsearch service. -# The default value is 'elasticsearch' and is declared in the init.d file. -# Note that this setting is only used by the init script. If changed, make sure that -# the configured user can read and write into the data, work, plugins and log directories. -# For systemd service, the user is usually configured in file /usr/lib/systemd/system/elasticsearch.service -{{ macros.config_row(config, 'ES_USER', '#ES_USER=elasticsearch', 0, true) }} -{{ macros.config_row(config, 'ES_GROUP', '#ES_GROUP=elasticsearch', 0, true) }} - -################################ -# System properties -################################ - -# Specifies the maximum file descriptor number that can be opened by this process -# When using Systemd, this setting is ignored and the LimitNOFILE defined in -# /usr/lib/systemd/system/elasticsearch.service takes precedence -{{ macros.config_row(config, 'MAX_OPEN_FILES', '#MAX_OPEN_FILES=65535', 0, true) }} - -# The maximum number of bytes of memory that may be locked into RAM -# Set to "unlimited" if you use the 'bootstrap.mlockall: true' option -# in elasticsearch.yml (ES_HEAP_SIZE must also be set). -# When using Systemd, the LimitMEMLOCK property must be set -# in /usr/lib/systemd/system/elasticsearch.service -{{ macros.config_row(config, 'MAX_LOCKED_MEMORY', '#MAX_LOCKED_MEMORY=unlimited', 0, true) }} - -# Maximum number of VMA (Virtual Memory Areas) a process can own -# When using Systemd, this setting is ignored and the 'vm.max_map_count' -# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf -{{ macros.config_row(config, 'MAX_MAP_COUNT', '#MAX_MAP_COUNT=262144', 0, true) }} - -{{ macros.config(config, [ - 'ES_HOME', - 'CONF_DIR', - 'CONF_FILE', - 'DATA_DIR', - 'LOG_DIR', - 'WORK_DIR', - 'PID_DIR', - 'ES_HEAP_SIZE', - 'ES_HEAP_NEWSIZE', - 'ES_DIRECT_SIZE', - 'ES_JAVA_OPTS', - 'ES_RESTART_ON_UPGRADE', - 'ES_GC_LOG_FILE', - 'ES_USER', - 'ES_GROUP', - 'MAX_OPEN_FILES', - 'MAX_LOCKED_MEMORY', - 'MAX_MAP_COUNT' -]) -}} diff --git a/roles/elasticsearch/templates/environment/1.7/default.j2 b/roles/elasticsearch/templates/environment/1.7/default.j2 deleted file mode 100644 index 4d1406767..000000000 --- a/roles/elasticsearch/templates/environment/1.7/default.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include '1.7/_base.j2' %} diff --git a/roles/elasticsearch/templates/environment/2/_base.j2 b/roles/elasticsearch/templates/environment/2/_base.j2 deleted file mode 100644 index b28744035..000000000 --- a/roles/elasticsearch/templates/environment/2/_base.j2 +++ /dev/null @@ -1,101 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_elasticsearch_environment -%} - -################################ -# Elasticsearch -################################ - -# Elasticsearch home directory -{{ macros.config_row(config, 'ES_HOME', '#ES_HOME=/usr/share/elasticsearch', 0, true) }} - -# Elasticsearch configuration directory -{{ macros.config_row(config, 'CONF_DIR', '#CONF_DIR=/etc/elasticsearch', 0, true) }} - -# Elasticsearch data directory -{{ macros.config_row(config, 'DATA_DIR', '#DATA_DIR=/var/lib/elasticsearch', 0, true) }} - -# Elasticsearch logs directory -{{ macros.config_row(config, 'LOG_DIR', '#LOG_DIR=/var/log/elasticsearch', 0, true) }} - -# Elasticsearch PID directory -{{ macros.config_row(config, 'PID_DIR', '#PID_DIR=/var/run/elasticsearch', 0, true) }} - -# Heap size defaults to 256m min, 1g max -# Set ES_HEAP_SIZE to 50% of available RAM, but no more than 31g -{{ macros.config_row(config, 'ES_HEAP_SIZE', '#ES_HEAP_SIZE=2g', 0, true) }} - -# Heap new generation -{{ macros.config_row(config, 'ES_HEAP_NEWSIZE', '#ES_HEAP_NEWSIZE=', 0, true) }} - -# Maximum direct memory -{{ macros.config_row(config, 'ES_DIRECT_SIZE', '#ES_DIRECT_SIZE=', 0, true) }} - -# Additional Java OPTS -{{ macros.config_row(config, 'ES_JAVA_OPTS', '#ES_JAVA_OPTS=', 0, true) }} - -# Configure restart on package upgrade (true, every other setting will lead to not restarting) -{{ macros.config_row(config, 'RESTART_ON_UPGRADE', '#RESTART_ON_UPGRADE=true', 0, true) }} - -# Path to the GC log file -{{ macros.config_row(config, 'ES_GC_LOG_FILE', '#ES_GC_LOG_FILE=/var/log/elasticsearch/gc.log', 0, true) }} - -################################ -# Elasticsearch service -################################ - -# SysV init.d -# -# When executing the init script, this user will be used to run the elasticsearch service. -# The default value is 'elasticsearch' and is declared in the init.d file. -# Note that this setting is only used by the init script. If changed, make sure that -# the configured user can read and write into the data, work, plugins and log directories. -# For systemd service, the user is usually configured in file /usr/lib/systemd/system/elasticsearch.service -{{ macros.config_row(config, 'ES_USER', '#ES_USER=elasticsearch', 0, true) }} -{{ macros.config_row(config, 'ES_GROUP', '#ES_GROUP=elasticsearch', 0, true) }} - -# The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process -{{ macros.config_row(config, 'ES_STARTUP_SLEEP_TIME', 5, 0) }} - -################################ -# System properties -################################ - -# Specifies the maximum file descriptor number that can be opened by this process -# When using Systemd, this setting is ignored and the LimitNOFILE defined in -# /usr/lib/systemd/system/elasticsearch.service takes precedence -{{ macros.config_row(config, 'MAX_OPEN_FILES', '#MAX_OPEN_FILES=65536', 0, true) }} - -# The maximum number of bytes of memory that may be locked into RAM -# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option -# in elasticsearch.yml (ES_HEAP_SIZE must also be set). -# When using Systemd, the LimitMEMLOCK property must be set -# in /usr/lib/systemd/system/elasticsearch.service -{{ macros.config_row(config, 'MAX_LOCKED_MEMORY', '#MAX_LOCKED_MEMORY=unlimited', 0, true) }} - -# Maximum number of VMA (Virtual Memory Areas) a process can own -# When using Systemd, this setting is ignored and the 'vm.max_map_count' -# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf -{{ macros.config_row(config, 'MAX_MAP_COUNT', '#MAX_MAP_COUNT=262144', 0, true) }} - -{{ macros.config(config, [ - 'ES_HOME', - 'CONF_DIR', - 'DATA_DIR', - 'LOG_DIR', - 'PID_DIR', - 'ES_HEAP_SIZE', - 'ES_HEAP_NEWSIZE', - 'ES_DIRECT_SIZE', - 'ES_JAVA_OPTS', - 'RESTART_ON_UPGRADE', - 'ES_GC_LOG_FILE', - 'ES_USER', - 'ES_GROUP', - 'ES_STARTUP_SLEEP_TIME', - 'MAX_OPEN_FILES', - 'MAX_LOCKED_MEMORY', - 'MAX_MAP_COUNT' -]) -}} diff --git a/roles/elasticsearch/templates/environment/2/default.j2 b/roles/elasticsearch/templates/environment/2/default.j2 deleted file mode 100644 index f94a160e1..000000000 --- a/roles/elasticsearch/templates/environment/2/default.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include '2/_base.j2' %} diff --git a/roles/elasticsearch/templates/environment/5/_base.j2 b/roles/elasticsearch/templates/environment/5/_base.j2 deleted file mode 100644 index cffc12131..000000000 --- a/roles/elasticsearch/templates/environment/5/_base.j2 +++ /dev/null @@ -1,88 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_elasticsearch_environment -%} - -################################ -# Elasticsearch -################################ - -# Elasticsearch home directory -{{ macros.config_row(config, 'ES_HOME', '#ES_HOME=/usr/share/elasticsearch', 0, true) }} - -# Elasticsearch Java path -{{ macros.config_row(config, 'JAVA_HOME', '#JAVA_HOME=', 0, true) }} - -# Elasticsearch configuration directory -{{ macros.config_row(config, 'CONF_DIR', '#CONF_DIR=/etc/elasticsearch', 0, true) }} - -# Elasticsearch data directory -{{ macros.config_row(config, 'DATA_DIR', '#DATA_DIR=/var/lib/elasticsearch', 0, true) }} - -# Elasticsearch logs directory -{{ macros.config_row(config, 'LOG_DIR', '#LOG_DIR=/var/log/elasticsearch', 0, true) }} - -# Elasticsearch PID directory -{{ macros.config_row(config, 'PID_DIR', '#PID_DIR=/var/run/elasticsearch', 0, true) }} - -# Additional Java OPTS -{{ macros.config_row(config, 'ES_JAVA_OPTS', '#ES_JAVA_OPTS=', 0, true) }} - -# Configure restart on package upgrade (true, every other setting will lead to not restarting) -{{ macros.config_row(config, 'RESTART_ON_UPGRADE', '#RESTART_ON_UPGRADE=true', 0, true) }} - -################################ -# Elasticsearch service -################################ - -# SysV init.d -# -# When executing the init script, this user will be used to run the elasticsearch service. -# The default value is 'elasticsearch' and is declared in the init.d file. -# Note that this setting is only used by the init script. If changed, make sure that -# the configured user can read and write into the data, work, plugins and log directories. -# For systemd service, the user is usually configured in file /usr/lib/systemd/system/elasticsearch.service -{{ macros.config_row(config, 'ES_USER', '#ES_USER=elasticsearch', 0, true) }} -{{ macros.config_row(config, 'ES_GROUP', '#ES_GROUP=elasticsearch', 0, true) }} - -# The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process -{{ macros.config_row(config, 'ES_STARTUP_SLEEP_TIME', 5, 0) }} - -################################ -# System properties -################################ - -# Specifies the maximum file descriptor number that can be opened by this process -# When using Systemd, this setting is ignored and the LimitNOFILE defined in -# /usr/lib/systemd/system/elasticsearch.service takes precedence -{{ macros.config_row(config, 'MAX_OPEN_FILES', '#MAX_OPEN_FILES=65536', 0, true) }} - -# The maximum number of bytes of memory that may be locked into RAM -# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option -# in elasticsearch.yml. -# When using systemd, LimitMEMLOCK must be set in a unit file such as -# /etc/systemd/system/elasticsearch.service.d/override.conf. -{{ macros.config_row(config, 'MAX_LOCKED_MEMORY', '#MAX_LOCKED_MEMORY=unlimited', 0, true) }} - -# Maximum number of VMA (Virtual Memory Areas) a process can own -# When using Systemd, this setting is ignored and the 'vm.max_map_count' -# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf -{{ macros.config_row(config, 'MAX_MAP_COUNT', '#MAX_MAP_COUNT=262144', 0, true) }} - -{{ macros.config(config, [ - 'ES_HOME', - 'JAVA_HOME', - 'CONF_DIR', - 'DATA_DIR', - 'LOG_DIR', - 'PID_DIR', - 'ES_JAVA_OPTS', - 'RESTART_ON_UPGRADE', - 'ES_USER', - 'ES_GROUP', - 'ES_STARTUP_SLEEP_TIME', - 'MAX_OPEN_FILES', - 'MAX_LOCKED_MEMORY', - 'MAX_MAP_COUNT' -]) -}} diff --git a/roles/elasticsearch/templates/environment/5/default.j2 b/roles/elasticsearch/templates/environment/5/default.j2 deleted file mode 100644 index e0d6a5a78..000000000 --- a/roles/elasticsearch/templates/environment/5/default.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include '5/_base.j2' %} diff --git a/roles/elasticsearch/templates/environment/6/_base.j2 b/roles/elasticsearch/templates/environment/6/_base.j2 deleted file mode 100644 index 188f43395..000000000 --- a/roles/elasticsearch/templates/environment/6/_base.j2 +++ /dev/null @@ -1,72 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_elasticsearch_environment -%} - -################################ -# Elasticsearch -################################ - -# Elasticsearch home directory -{{ macros.config_row(config, 'ES_HOME', '#ES_HOME=/usr/share/elasticsearch', 0, true) }} - -# Elasticsearch Java path -{{ macros.config_row(config, 'JAVA_HOME', '#JAVA_HOME=', 0, true) }} - -# Elasticsearch configuration directory -{{ macros.config_row(config, 'ES_PATH_CONF', '/etc/elasticsearch', 0) }} - -# Elasticsearch PID directory -{{ macros.config_row(config, 'PID_DIR', '#PID_DIR=/var/run/elasticsearch', 0, true) }} - -# Additional Java OPTS -{{ macros.config_row(config, 'ES_JAVA_OPTS', '#ES_JAVA_OPTS=', 0, true) }} - -# Configure restart on package upgrade (true, every other setting will lead to not restarting) -{{ macros.config_row(config, 'RESTART_ON_UPGRADE', '#RESTART_ON_UPGRADE=true', 0, true) }} - -################################ -# Elasticsearch service -################################ - -# SysV init.d -# -# The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process -{{ macros.config_row(config, 'ES_STARTUP_SLEEP_TIME', 5, 0) }} - -################################ -# System properties -################################ - -# Specifies the maximum file descriptor number that can be opened by this process -# When using Systemd, this setting is ignored and the LimitNOFILE defined in -# /usr/lib/systemd/system/elasticsearch.service takes precedence -{{ macros.config_row(config, 'MAX_OPEN_FILES', '#MAX_OPEN_FILES=65535', 0, true) }} - -# The maximum number of bytes of memory that may be locked into RAM -# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option -# in elasticsearch.yml. -# When using systemd, LimitMEMLOCK must be set in a unit file such as -# /etc/systemd/system/elasticsearch.service.d/override.conf. -{{ macros.config_row(config, 'MAX_LOCKED_MEMORY', '#MAX_LOCKED_MEMORY=unlimited', 0, true) }} - -# Maximum number of VMA (Virtual Memory Areas) a process can own -# When using Systemd, this setting is ignored and the 'vm.max_map_count' -# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf -{{ macros.config_row(config, 'MAX_MAP_COUNT', '#MAX_MAP_COUNT=262144', 0, true) }} - -{{ macros.config(config, [ - 'ES_HOME', - 'JAVA_HOME', - 'ES_PATH_CONF', - 'PID_DIR', - 'ES_JAVA_OPTS', - 'RESTART_ON_UPGRADE', - 'ES_USER', - 'ES_GROUP', - 'ES_STARTUP_SLEEP_TIME', - 'MAX_OPEN_FILES', - 'MAX_LOCKED_MEMORY', - 'MAX_MAP_COUNT' -]) -}} diff --git a/roles/elasticsearch/templates/environment/6/default.j2 b/roles/elasticsearch/templates/environment/6/default.j2 deleted file mode 100644 index 04731e145..000000000 --- a/roles/elasticsearch/templates/environment/6/default.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include '6/_base.j2' %} diff --git a/roles/elasticsearch/templates/environment/7/_base.j2 b/roles/elasticsearch/templates/environment/7/_base.j2 deleted file mode 100644 index 188f43395..000000000 --- a/roles/elasticsearch/templates/environment/7/_base.j2 +++ /dev/null @@ -1,72 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_elasticsearch_environment -%} - -################################ -# Elasticsearch -################################ - -# Elasticsearch home directory -{{ macros.config_row(config, 'ES_HOME', '#ES_HOME=/usr/share/elasticsearch', 0, true) }} - -# Elasticsearch Java path -{{ macros.config_row(config, 'JAVA_HOME', '#JAVA_HOME=', 0, true) }} - -# Elasticsearch configuration directory -{{ macros.config_row(config, 'ES_PATH_CONF', '/etc/elasticsearch', 0) }} - -# Elasticsearch PID directory -{{ macros.config_row(config, 'PID_DIR', '#PID_DIR=/var/run/elasticsearch', 0, true) }} - -# Additional Java OPTS -{{ macros.config_row(config, 'ES_JAVA_OPTS', '#ES_JAVA_OPTS=', 0, true) }} - -# Configure restart on package upgrade (true, every other setting will lead to not restarting) -{{ macros.config_row(config, 'RESTART_ON_UPGRADE', '#RESTART_ON_UPGRADE=true', 0, true) }} - -################################ -# Elasticsearch service -################################ - -# SysV init.d -# -# The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process -{{ macros.config_row(config, 'ES_STARTUP_SLEEP_TIME', 5, 0) }} - -################################ -# System properties -################################ - -# Specifies the maximum file descriptor number that can be opened by this process -# When using Systemd, this setting is ignored and the LimitNOFILE defined in -# /usr/lib/systemd/system/elasticsearch.service takes precedence -{{ macros.config_row(config, 'MAX_OPEN_FILES', '#MAX_OPEN_FILES=65535', 0, true) }} - -# The maximum number of bytes of memory that may be locked into RAM -# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option -# in elasticsearch.yml. -# When using systemd, LimitMEMLOCK must be set in a unit file such as -# /etc/systemd/system/elasticsearch.service.d/override.conf. -{{ macros.config_row(config, 'MAX_LOCKED_MEMORY', '#MAX_LOCKED_MEMORY=unlimited', 0, true) }} - -# Maximum number of VMA (Virtual Memory Areas) a process can own -# When using Systemd, this setting is ignored and the 'vm.max_map_count' -# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf -{{ macros.config_row(config, 'MAX_MAP_COUNT', '#MAX_MAP_COUNT=262144', 0, true) }} - -{{ macros.config(config, [ - 'ES_HOME', - 'JAVA_HOME', - 'ES_PATH_CONF', - 'PID_DIR', - 'ES_JAVA_OPTS', - 'RESTART_ON_UPGRADE', - 'ES_USER', - 'ES_GROUP', - 'ES_STARTUP_SLEEP_TIME', - 'MAX_OPEN_FILES', - 'MAX_LOCKED_MEMORY', - 'MAX_MAP_COUNT' -]) -}} diff --git a/roles/elasticsearch/templates/environment/7/default.j2 b/roles/elasticsearch/templates/environment/7/default.j2 deleted file mode 100644 index 55c2acf0e..000000000 --- a/roles/elasticsearch/templates/environment/7/default.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{% include '7/_base.j2' %} diff --git a/roles/elasticsearch/templates/environment/_base.j2 b/roles/elasticsearch/templates/environment/_base.j2 deleted file mode 100644 index 89a7fc51c..000000000 --- a/roles/elasticsearch/templates/environment/_base.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{#- Deprecated -#} - -{%- include manala_elasticsearch_version|string ~ '/default.j2' -%} diff --git a/roles/elasticsearch/templates/environment/_default.j2 b/roles/elasticsearch/templates/environment/_default.j2 index 344f60f0d..fb697e946 100644 --- a/roles/elasticsearch/templates/environment/_default.j2 +++ b/roles/elasticsearch/templates/environment/_default.j2 @@ -2,12 +2,7 @@ {%- if environment is mapping -%} -{{ environment | manala_environment }} - -{%- elif environment is iterable and environment is not string -%} - -{#- Deprecated -#} -{%- include '_base.j2' -%} +{{ environment | manala.roles.environment }} {%- else -%} diff --git a/roles/elasticsearch/templates/environment/_macros.j2 b/roles/elasticsearch/templates/environment/_macros.j2 deleted file mode 100644 index 02b082f11..000000000 --- a/roles/elasticsearch/templates/environment/_macros.j2 +++ /dev/null @@ -1,62 +0,0 @@ -{#- Deprecated -#} - -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ parameter|indent(indent, true) }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.iteritems() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }}{{ '\n' }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.iteritems() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default|indent(indent, true) }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {{ _config_parameter_key(key)|indent(indent, true) }}={{ _config_parameter_value(value) }} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - {{ key }} -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} -{%- if value is sameas none -%} -{%- elif value is sameas true -%} - true -{%- elif value is sameas false -%} - false -{%- elif value is string -%} - "{{ value }}" -{%- elif value is number -%} - {{ value }} -{%- endif -%} -{%- endmacro -%} diff --git a/roles/elasticsearch/templates/environment/elasticsearch/1.7/elasticsearch.j2 b/roles/elasticsearch/templates/environment/elasticsearch/1.7/elasticsearch.j2 deleted file mode 100644 index 3e6575272..000000000 --- a/roles/elasticsearch/templates/environment/elasticsearch/1.7/elasticsearch.j2 +++ /dev/null @@ -1,101 +0,0 @@ -{% set environment = manala_elasticsearch_environment|default({}, true) -%} - -################################ -# Elasticsearch -################################ - -# Elasticsearch home directory -{{ environment | manala_environment_parameter('ES_HOME', comment='#ES_HOME=/usr/share/elasticsearch') }} - -# Elasticsearch configuration directory -{{ environment | manala_environment_parameter('CONF_DIR', comment='#CONF_DIR=/etc/elasticsearch') }} - -# Elasticsearch configuration file -{{ environment | manala_environment_parameter('CONF_FILE', comment='#CONF_FILE=$CONF_DIR/elasticsearch.yml') }} - -# Elasticsearch data directory -{{ environment | manala_environment_parameter('DATA_DIR', comment='#DATA_DIR=/var/lib/elasticsearch') }} - -# Elasticsearch logs directory -{{ environment | manala_environment_parameter('LOG_DIR', comment='#LOG_DIR=/var/log/elasticsearch') }} - -# Elasticsearch work directory -{{ environment | manala_environment_parameter('WORK_DIR', comment='#WORK_DIR=/tmp/elasticsearch') }} - -# Elasticsearch PID directory -{{ environment | manala_environment_parameter('PID_DIR', comment='#PID_DIR=/var/run/elasticsearch') }} - -# Heap size defaults to 256m min, 1g max -# Set ES_HEAP_SIZE to 50% of available RAM, but no more than 31g -{{ environment | manala_environment_parameter('ES_HEAP_SIZE', comment='#ES_HEAP_SIZE=2g') }} - -# Heap new generation -{{ environment | manala_environment_parameter('ES_HEAP_NEWSIZE', comment='#ES_HEAP_NEWSIZE=') }} - -# Maximum direct memory -{{ environment | manala_environment_parameter('ES_DIRECT_SIZE', comment='#ES_DIRECT_SIZE=') }} - -# Additional Java OPTS -{{ environment | manala_environment_parameter('ES_JAVA_OPTS', comment='#ES_JAVA_OPTS=') }} - -# Configure restart on package upgrade (true, every other setting will lead to not restarting) -{{ environment | manala_environment_parameter('ES_RESTART_ON_UPGRADE', comment='#ES_RESTART_ON_UPGRADE=true') }} - -# Path to the GC log file -{{ environment | manala_environment_parameter('ES_GC_LOG_FILE', comment='#ES_GC_LOG_FILE=/var/log/elasticsearch/gc.log') }} - -################################ -# Elasticsearch service -################################ - -# SysV init.d -# -# When executing the init script, this user will be used to run the elasticsearch service. -# The default value is 'elasticsearch' and is declared in the init.d file. -# Note that this setting is only used by the init script. If changed, make sure that -# the configured user can read and write into the data, work, plugins and log directories. -# For systemd service, the user is usually configured in file /usr/lib/systemd/system/elasticsearch.service -{{ environment | manala_environment_parameter('ES_USER', comment='#ES_USER=elasticsearch') }} -{{ environment | manala_environment_parameter('ES_GROUP', comment='#ES_GROUP=elasticsearch') }} - -################################ -# System properties -################################ - -# Specifies the maximum file descriptor number that can be opened by this process -# When using Systemd, this setting is ignored and the LimitNOFILE defined in -# /usr/lib/systemd/system/elasticsearch.service takes precedence -{{ environment | manala_environment_parameter('MAX_OPEN_FILES', default=65535, comment=True) }} - -# The maximum number of bytes of memory that may be locked into RAM -# Set to "unlimited" if you use the 'bootstrap.mlockall: true' option -# in elasticsearch.yml (ES_HEAP_SIZE must also be set). -# When using Systemd, the LimitMEMLOCK property must be set -# in /usr/lib/systemd/system/elasticsearch.service -{{ environment | manala_environment_parameter('MAX_LOCKED_MEMORY', comment='#MAX_LOCKED_MEMORY=unlimited') }} - -# Maximum number of VMA (Virtual Memory Areas) a process can own -# When using Systemd, this setting is ignored and the 'vm.max_map_count' -# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf -{{ environment | manala_environment_parameter('MAX_MAP_COUNT', default=262144, comment=True) }} - -{{ environment | manala_environment(exclude=[ - 'ES_HOME', - 'CONF_DIR', - 'CONF_FILE', - 'DATA_DIR', - 'LOG_DIR', - 'WORK_DIR', - 'PID_DIR', - 'ES_HEAP_SIZE', - 'ES_HEAP_NEWSIZE', - 'ES_DIRECT_SIZE', - 'ES_JAVA_OPTS', - 'ES_RESTART_ON_UPGRADE', - 'ES_GC_LOG_FILE', - 'ES_USER', - 'ES_GROUP', - 'MAX_OPEN_FILES', - 'MAX_LOCKED_MEMORY', - 'MAX_MAP_COUNT', -]) }} diff --git a/roles/elasticsearch/templates/environment/elasticsearch/2/elasticsearch.j2 b/roles/elasticsearch/templates/environment/elasticsearch/2/elasticsearch.j2 index b3c32a14c..964de6438 100644 --- a/roles/elasticsearch/templates/environment/elasticsearch/2/elasticsearch.j2 +++ b/roles/elasticsearch/templates/environment/elasticsearch/2/elasticsearch.j2 @@ -5,38 +5,38 @@ ################################ # Elasticsearch home directory -{{ environment | manala_environment_parameter('ES_HOME', comment='#ES_HOME=/usr/share/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('ES_HOME', comment='#ES_HOME=/usr/share/elasticsearch') }} # Elasticsearch configuration directory -{{ environment | manala_environment_parameter('CONF_DIR', comment='#CONF_DIR=/etc/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('CONF_DIR', comment='#CONF_DIR=/etc/elasticsearch') }} # Elasticsearch data directory -{{ environment | manala_environment_parameter('DATA_DIR', comment='#DATA_DIR=/var/lib/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('DATA_DIR', comment='#DATA_DIR=/var/lib/elasticsearch') }} # Elasticsearch logs directory -{{ environment | manala_environment_parameter('LOG_DIR', comment='#LOG_DIR=/var/log/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('LOG_DIR', comment='#LOG_DIR=/var/log/elasticsearch') }} # Elasticsearch PID directory -{{ environment | manala_environment_parameter('PID_DIR', comment='#PID_DIR=/var/run/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('PID_DIR', comment='#PID_DIR=/var/run/elasticsearch') }} # Heap size defaults to 256m min, 1g max # Set ES_HEAP_SIZE to 50% of available RAM, but no more than 31g -{{ environment | manala_environment_parameter('ES_HEAP_SIZE', comment='#ES_HEAP_SIZE=2g') }} +{{ environment | manala.roles.environment_parameter('ES_HEAP_SIZE', comment='#ES_HEAP_SIZE=2g') }} # Heap new generation -{{ environment | manala_environment_parameter('ES_HEAP_NEWSIZE', comment='#ES_HEAP_NEWSIZE=') }} +{{ environment | manala.roles.environment_parameter('ES_HEAP_NEWSIZE', comment='#ES_HEAP_NEWSIZE=') }} # Maximum direct memory -{{ environment | manala_environment_parameter('ES_DIRECT_SIZE', comment='#ES_DIRECT_SIZE=') }} +{{ environment | manala.roles.environment_parameter('ES_DIRECT_SIZE', comment='#ES_DIRECT_SIZE=') }} # Additional Java OPTS -{{ environment | manala_environment_parameter('ES_JAVA_OPTS', comment='#ES_JAVA_OPTS=') }} +{{ environment | manala.roles.environment_parameter('ES_JAVA_OPTS', comment='#ES_JAVA_OPTS=') }} # Configure restart on package upgrade (true, every other setting will lead to not restarting) -{{ environment | manala_environment_parameter('RESTART_ON_UPGRADE', comment='#RESTART_ON_UPGRADE=true') }} +{{ environment | manala.roles.environment_parameter('RESTART_ON_UPGRADE', comment='#RESTART_ON_UPGRADE=true') }} # Path to the GC log file -{{ environment | manala_environment_parameter('ES_GC_LOG_FILE', comment='#ES_GC_LOG_FILE=/var/log/elasticsearch/gc.log') }} +{{ environment | manala.roles.environment_parameter('ES_GC_LOG_FILE', comment='#ES_GC_LOG_FILE=/var/log/elasticsearch/gc.log') }} ################################ # Elasticsearch service @@ -49,11 +49,11 @@ # Note that this setting is only used by the init script. If changed, make sure that # the configured user can read and write into the data, work, plugins and log directories. # For systemd service, the user is usually configured in file /usr/lib/systemd/system/elasticsearch.service -{{ environment | manala_environment_parameter('ES_USER', comment='#ES_USER=elasticsearch') }} -{{ environment | manala_environment_parameter('ES_GROUP', comment='#ES_GROUP=elasticsearch') }} +{{ environment | manala.roles.environment_parameter('ES_USER', comment='#ES_USER=elasticsearch') }} +{{ environment | manala.roles.environment_parameter('ES_GROUP', comment='#ES_GROUP=elasticsearch') }} # The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process -{{ environment | manala_environment_parameter('ES_STARTUP_SLEEP_TIME', default=5) }} +{{ environment | manala.roles.environment_parameter('ES_STARTUP_SLEEP_TIME', default=5) }} ################################ # System properties @@ -62,21 +62,21 @@ # Specifies the maximum file descriptor number that can be opened by this process # When using Systemd, this setting is ignored and the LimitNOFILE defined in # /usr/lib/systemd/system/elasticsearch.service takes precedence -{{ environment | manala_environment_parameter('MAX_OPEN_FILES', default=65536, comment=True) }} +{{ environment | manala.roles.environment_parameter('MAX_OPEN_FILES', default=65536, comment=True) }} # The maximum number of bytes of memory that may be locked into RAM # Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option # in elasticsearch.yml (ES_HEAP_SIZE must also be set). # When using Systemd, the LimitMEMLOCK property must be set # in /usr/lib/systemd/system/elasticsearch.service -{{ environment | manala_environment_parameter('MAX_LOCKED_MEMORY', comment='#MAX_LOCKED_MEMORY=unlimited') }} +{{ environment | manala.roles.environment_parameter('MAX_LOCKED_MEMORY', comment='#MAX_LOCKED_MEMORY=unlimited') }} # Maximum number of VMA (Virtual Memory Areas) a process can own # When using Systemd, this setting is ignored and the 'vm.max_map_count' # property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf -{{ environment | manala_environment_parameter('MAX_MAP_COUNT', default=262144, comment=True) }} +{{ environment | manala.roles.environment_parameter('MAX_MAP_COUNT', default=262144, comment=True) }} -{{ environment | manala_environment(exclude=[ +{{ environment | manala.roles.environment(exclude=[ 'ES_HOME', 'CONF_DIR', 'DATA_DIR', diff --git a/roles/elasticsearch/templates/environment/elasticsearch/5/elasticsearch.j2 b/roles/elasticsearch/templates/environment/elasticsearch/5/elasticsearch.j2 index 7eed86459..868127b49 100644 --- a/roles/elasticsearch/templates/environment/elasticsearch/5/elasticsearch.j2 +++ b/roles/elasticsearch/templates/environment/elasticsearch/5/elasticsearch.j2 @@ -5,28 +5,28 @@ ################################ # Elasticsearch home directory -{{ environment | manala_environment_parameter('ES_HOME', comment='#ES_HOME=/usr/share/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('ES_HOME', comment='#ES_HOME=/usr/share/elasticsearch') }} # Elasticsearch Java path -{{ environment | manala_environment_parameter('JAVA_HOME', comment='#JAVA_HOME=') }} +{{ environment | manala.roles.environment_parameter('JAVA_HOME', comment='#JAVA_HOME=') }} # Elasticsearch configuration directory -{{ environment | manala_environment_parameter('CONF_DIR', comment='#CONF_DIR=/etc/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('CONF_DIR', comment='#CONF_DIR=/etc/elasticsearch') }} # Elasticsearch data directory -{{ environment | manala_environment_parameter('DATA_DIR', comment='#DATA_DIR=/var/lib/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('DATA_DIR', comment='#DATA_DIR=/var/lib/elasticsearch') }} # Elasticsearch logs directory -{{ environment | manala_environment_parameter('LOG_DIR', comment='#LOG_DIR=/var/log/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('LOG_DIR', comment='#LOG_DIR=/var/log/elasticsearch') }} # Elasticsearch PID directory -{{ environment | manala_environment_parameter('PID_DIR', comment='#PID_DIR=/var/run/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('PID_DIR', comment='#PID_DIR=/var/run/elasticsearch') }} # Additional Java OPTS -{{ environment | manala_environment_parameter('ES_JAVA_OPTS', comment='#ES_JAVA_OPTS=') }} +{{ environment | manala.roles.environment_parameter('ES_JAVA_OPTS', comment='#ES_JAVA_OPTS=') }} # Configure restart on package upgrade (true, every other setting will lead to not restarting) -{{ environment | manala_environment_parameter('RESTART_ON_UPGRADE', comment='#RESTART_ON_UPGRADE=true') }} +{{ environment | manala.roles.environment_parameter('RESTART_ON_UPGRADE', comment='#RESTART_ON_UPGRADE=true') }} ################################ # Elasticsearch service @@ -39,11 +39,11 @@ # Note that this setting is only used by the init script. If changed, make sure that # the configured user can read and write into the data, work, plugins and log directories. # For systemd service, the user is usually configured in file /usr/lib/systemd/system/elasticsearch.service -{{ environment | manala_environment_parameter('ES_USER', comment='#ES_USER=elasticsearch') }} -{{ environment | manala_environment_parameter('ES_GROUP', comment='#ES_GROUP=elasticsearch') }} +{{ environment | manala.roles.environment_parameter('ES_USER', comment='#ES_USER=elasticsearch') }} +{{ environment | manala.roles.environment_parameter('ES_GROUP', comment='#ES_GROUP=elasticsearch') }} # The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process -{{ environment | manala_environment_parameter('ES_STARTUP_SLEEP_TIME', default=5) }} +{{ environment | manala.roles.environment_parameter('ES_STARTUP_SLEEP_TIME', default=5) }} ################################ # System properties @@ -52,21 +52,21 @@ # Specifies the maximum file descriptor number that can be opened by this process # When using Systemd, this setting is ignored and the LimitNOFILE defined in # /usr/lib/systemd/system/elasticsearch.service takes precedence -{{ environment | manala_environment_parameter('MAX_OPEN_FILES', default=65536, comment=True) }} +{{ environment | manala.roles.environment_parameter('MAX_OPEN_FILES', default=65536, comment=True) }} # The maximum number of bytes of memory that may be locked into RAM # Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option # in elasticsearch.yml. # When using systemd, LimitMEMLOCK must be set in a unit file such as # /etc/systemd/system/elasticsearch.service.d/override.conf. -{{ environment | manala_environment_parameter('MAX_LOCKED_MEMORY', comment='#MAX_LOCKED_MEMORY=unlimited') }} +{{ environment | manala.roles.environment_parameter('MAX_LOCKED_MEMORY', comment='#MAX_LOCKED_MEMORY=unlimited') }} # Maximum number of VMA (Virtual Memory Areas) a process can own # When using Systemd, this setting is ignored and the 'vm.max_map_count' # property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf -{{ environment | manala_environment_parameter('MAX_MAP_COUNT', default=262144, comment='#MAX_MAP_COUNT=262144') }} +{{ environment | manala.roles.environment_parameter('MAX_MAP_COUNT', default=262144, comment='#MAX_MAP_COUNT=262144') }} -{{ environment | manala_environment(exclude=[ +{{ environment | manala.roles.environment(exclude=[ 'ES_HOME', 'JAVA_HOME', 'CONF_DIR', diff --git a/roles/elasticsearch/templates/environment/elasticsearch/6/elasticsearch.j2 b/roles/elasticsearch/templates/environment/elasticsearch/6/elasticsearch.j2 index 90c8cc313..ce7838935 100644 --- a/roles/elasticsearch/templates/environment/elasticsearch/6/elasticsearch.j2 +++ b/roles/elasticsearch/templates/environment/elasticsearch/6/elasticsearch.j2 @@ -5,22 +5,22 @@ ################################ # Elasticsearch home directory -{{ environment | manala_environment_parameter('ES_HOME', comment='#ES_HOME=/usr/share/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('ES_HOME', comment='#ES_HOME=/usr/share/elasticsearch') }} # Elasticsearch Java path -{{ environment | manala_environment_parameter('JAVA_HOME', comment='#JAVA_HOME=') }} +{{ environment | manala.roles.environment_parameter('JAVA_HOME', comment='#JAVA_HOME=') }} # Elasticsearch configuration directory -{{ environment | manala_environment_parameter('ES_PATH_CONF', comment='ES_PATH_CONF=/etc/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('ES_PATH_CONF', comment='ES_PATH_CONF=/etc/elasticsearch') }} # Elasticsearch PID directory -{{ environment | manala_environment_parameter('PID_DIR', comment='#PID_DIR=/var/run/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('PID_DIR', comment='#PID_DIR=/var/run/elasticsearch') }} # Additional Java OPTS -{{ environment | manala_environment_parameter('ES_JAVA_OPTS', comment='#ES_JAVA_OPTS=') }} +{{ environment | manala.roles.environment_parameter('ES_JAVA_OPTS', comment='#ES_JAVA_OPTS=') }} # Configure restart on package upgrade (true, every other setting will lead to not restarting) -{{ environment | manala_environment_parameter('RESTART_ON_UPGRADE', comment='#RESTART_ON_UPGRADE=true') }} +{{ environment | manala.roles.environment_parameter('RESTART_ON_UPGRADE', comment='#RESTART_ON_UPGRADE=true') }} ################################ # Elasticsearch service @@ -29,7 +29,7 @@ # SysV init.d # # The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process -{{ environment | manala_environment_parameter('ES_STARTUP_SLEEP_TIME', default=5) }} +{{ environment | manala.roles.environment_parameter('ES_STARTUP_SLEEP_TIME', default=5) }} ################################ # System properties @@ -38,21 +38,21 @@ # Specifies the maximum file descriptor number that can be opened by this process # When using Systemd, this setting is ignored and the LimitNOFILE defined in # /usr/lib/systemd/system/elasticsearch.service takes precedence -{{ environment | manala_environment_parameter('MAX_OPEN_FILES', default=65535, comment=True) }} +{{ environment | manala.roles.environment_parameter('MAX_OPEN_FILES', default=65535, comment=True) }} # The maximum number of bytes of memory that may be locked into RAM # Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option # in elasticsearch.yml. # When using systemd, LimitMEMLOCK must be set in a unit file such as # /etc/systemd/system/elasticsearch.service.d/override.conf. -{{ environment | manala_environment_parameter('MAX_LOCKED_MEMORY', comment='#MAX_LOCKED_MEMORY=unlimited') }} +{{ environment | manala.roles.environment_parameter('MAX_LOCKED_MEMORY', comment='#MAX_LOCKED_MEMORY=unlimited') }} # Maximum number of VMA (Virtual Memory Areas) a process can own # When using Systemd, this setting is ignored and the 'vm.max_map_count' # property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf -{{ environment | manala_environment_parameter('MAX_MAP_COUNT', default=262144, comment=True) }} +{{ environment | manala.roles.environment_parameter('MAX_MAP_COUNT', default=262144, comment=True) }} -{{ environment | manala_environment(exclude=[ +{{ environment | manala.roles.environment(exclude=[ 'ES_HOME', 'JAVA_HOME', 'ES_PATH_CONF', diff --git a/roles/elasticsearch/templates/environment/elasticsearch/7/elasticsearch.j2 b/roles/elasticsearch/templates/environment/elasticsearch/7/elasticsearch.j2 index d9f364d9f..9dc6c3d38 100644 --- a/roles/elasticsearch/templates/environment/elasticsearch/7/elasticsearch.j2 +++ b/roles/elasticsearch/templates/environment/elasticsearch/7/elasticsearch.j2 @@ -5,23 +5,23 @@ ################################ # Elasticsearch home directory -{{ environment | manala_environment_parameter('ES_HOME', comment='#ES_HOME=/usr/share/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('ES_HOME', comment='#ES_HOME=/usr/share/elasticsearch') }} # Elasticsearch Java path -{{ environment | manala_environment_parameter('JAVA_HOME', comment='#JAVA_HOME=') }} +{{ environment | manala.roles.environment_parameter('JAVA_HOME', comment='#JAVA_HOME=') }} # Elasticsearch configuration directory # Note: this setting will be shared with command-line tools -{{ environment | manala_environment_parameter('ES_PATH_CONF', comment='ES_PATH_CONF=/etc/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('ES_PATH_CONF', comment='ES_PATH_CONF=/etc/elasticsearch') }} # Elasticsearch PID directory -{{ environment | manala_environment_parameter('PID_DIR', comment='#PID_DIR=/var/run/elasticsearch') }} +{{ environment | manala.roles.environment_parameter('PID_DIR', comment='#PID_DIR=/var/run/elasticsearch') }} # Additional Java OPTS -{{ environment | manala_environment_parameter('ES_JAVA_OPTS', comment='#ES_JAVA_OPTS=') }} +{{ environment | manala.roles.environment_parameter('ES_JAVA_OPTS', comment='#ES_JAVA_OPTS=') }} # Configure restart on package upgrade (true, every other setting will lead to not restarting) -{{ environment | manala_environment_parameter('RESTART_ON_UPGRADE', comment='#RESTART_ON_UPGRADE=true') }} +{{ environment | manala.roles.environment_parameter('RESTART_ON_UPGRADE', comment='#RESTART_ON_UPGRADE=true') }} ################################ # Elasticsearch service @@ -30,7 +30,7 @@ # SysV init.d # # The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process -{{ environment | manala_environment_parameter('ES_STARTUP_SLEEP_TIME', default=5) }} +{{ environment | manala.roles.environment_parameter('ES_STARTUP_SLEEP_TIME', default=5) }} ################################ # System properties @@ -39,21 +39,21 @@ # Specifies the maximum file descriptor number that can be opened by this process # When using Systemd, this setting is ignored and the LimitNOFILE defined in # /usr/lib/systemd/system/elasticsearch.service takes precedence -{{ environment | manala_environment_parameter('MAX_OPEN_FILES', default=65535, comment=True) }} +{{ environment | manala.roles.environment_parameter('MAX_OPEN_FILES', default=65535, comment=True) }} # The maximum number of bytes of memory that may be locked into RAM # Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option # in elasticsearch.yml. # When using systemd, LimitMEMLOCK must be set in a unit file such as # /etc/systemd/system/elasticsearch.service.d/override.conf. -{{ environment | manala_environment_parameter('MAX_LOCKED_MEMORY', comment='#MAX_LOCKED_MEMORY=unlimited') }} +{{ environment | manala.roles.environment_parameter('MAX_LOCKED_MEMORY', comment='#MAX_LOCKED_MEMORY=unlimited') }} # Maximum number of VMA (Virtual Memory Areas) a process can own # When using Systemd, this setting is ignored and the 'vm.max_map_count' # property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf -{{ environment | manala_environment_parameter('MAX_MAP_COUNT', default=262144, comment=True) }} +{{ environment | manala.roles.environment_parameter('MAX_MAP_COUNT', default=262144, comment=True) }} -{{ environment | manala_environment(exclude=[ +{{ environment | manala.roles.environment(exclude=[ 'ES_HOME', 'JAVA_HOME', 'ES_PATH_CONF', diff --git a/roles/elasticsearch/templates/environment/empty.j2 b/roles/elasticsearch/templates/environment/empty.j2 deleted file mode 100644 index 27b777ce2..000000000 --- a/roles/elasticsearch/templates/environment/empty.j2 +++ /dev/null @@ -1,5 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{{ macros.config(manala_elasticsearch_environment) }} diff --git a/roles/elasticsearch/tests/.gitignore b/roles/elasticsearch/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/elasticsearch/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/elasticsearch/tests/0000_default.1.7.goss.yml b/roles/elasticsearch/tests/0000_default.1.7.goss.yml deleted file mode 100644 index 602099358..000000000 --- a/roles/elasticsearch/tests/0000_default.1.7.goss.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- - -package: - elasticsearch: - installed: true - -service: - elasticsearch: - enabled: true - running: true - -http: - http://localhost:9200/?pretty: - status: 200 - timeout: 2000 - body: - - '/"status" : 200,/' - - '/"number" : "1.7/' - -command: - /usr/share/elasticsearch/bin/plugin --list: - exit-status: 0 - stdout: - - "- head" diff --git a/roles/elasticsearch/tests/0000_default.1.7.yml b/roles/elasticsearch/tests/0000_default.1.7.yml deleted file mode 100644 index 6fa14821b..000000000 --- a/roles/elasticsearch/tests/0000_default.1.7.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: - - debian.jessie - become: true - tasks: - - - block: - - import_tasks: pre_tasks/elasticsearch_1.7.yml - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['jessie'] - - apt: - name: "{{ { - 'jessie': 'openjdk-8-jre-headless', - }[ansible_distribution_release] }}" - install_recommends: false - - - block: - - import_role: - name: manala.elasticsearch - vars: - manala_elasticsearch_plugins: - - mobz/elasticsearch-head - always: - - name: Wait for pretty response - uri: - url: http://localhost:9200/?pretty - register: result - until: result.status == 200 - retries: 60 - delay: 1 - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/elasticsearch/tests/0001_default.2.yml b/roles/elasticsearch/tests/0001_default.2.yml deleted file mode 100644 index 4b46c9435..000000000 --- a/roles/elasticsearch/tests/0001_default.2.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: - - debian.jessie - - debian.stretch - become: true - tasks: - - - block: - - import_tasks: pre_tasks/elasticsearch_2.yml - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['jessie'] - - apt: - name: "{{ { - 'jessie': 'openjdk-8-jre-headless', - 'stretch': 'openjdk-8-jre-headless', - }[ansible_distribution_release] }}" - install_recommends: false - - - block: - - import_role: - name: manala.elasticsearch - vars: - manala_elasticsearch_plugins: - - mobz/elasticsearch-head - always: - - name: Wait for pretty response - uri: - url: http://localhost:9200/?pretty - register: result - until: result.status == 200 - retries: 60 - delay: 1 - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/elasticsearch/tests/0002_default.5.yml b/roles/elasticsearch/tests/0002_default.5.yml deleted file mode 100644 index 301edc782..000000000 --- a/roles/elasticsearch/tests/0002_default.5.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/elasticsearch_5.yml - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['jessie'] - - apt: - name: "{{ { - 'jessie': 'openjdk-8-jre-headless', - 'stretch': 'openjdk-8-jre-headless', - 'buster': 'openjdk-11-jre-headless', - }[ansible_distribution_release] }}" - install_recommends: false - - - block: - - import_role: - name: manala.elasticsearch - vars: - manala_elasticsearch_plugins: - - analysis-icu - always: - - name: Wait for pretty response - uri: - url: http://localhost:9200/?pretty - register: result - until: result.status == 200 - retries: 60 - delay: 1 - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/elasticsearch/tests/0003_default.6.yml b/roles/elasticsearch/tests/0003_default.6.yml deleted file mode 100644 index 33e4a1ed7..000000000 --- a/roles/elasticsearch/tests/0003_default.6.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/elasticsearch_6.yml - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['jessie'] - - apt: - name: "{{ { - 'jessie': 'openjdk-8-jre-headless', - 'stretch': 'openjdk-8-jre-headless', - 'buster': 'openjdk-11-jre-headless', - }[ansible_distribution_release] }}" - install_recommends: false - - - block: - - import_role: - name: manala.elasticsearch - vars: - manala_elasticsearch_plugins: - - analysis-icu - always: - - name: Wait for pretty response - uri: - url: http://localhost:9200/?pretty - register: result - until: result.status == 200 - retries: 60 - delay: 1 - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/elasticsearch/tests/0004_default.7.yml b/roles/elasticsearch/tests/0004_default.7.yml deleted file mode 100644 index 2a5b6480d..000000000 --- a/roles/elasticsearch/tests/0004_default.7.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/elasticsearch_7.yml - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['jessie'] - - apt: - name: "{{ { - 'jessie': 'openjdk-8-jre-headless', - 'stretch': 'openjdk-8-jre-headless', - 'buster': 'openjdk-11-jre-headless', - }[ansible_distribution_release] }}" - install_recommends: false - - - block: - - import_role: - name: manala.elasticsearch - vars: - manala_elasticsearch_plugins: - - analysis-icu - always: - - name: Wait for pretty response - uri: - url: http://localhost:9200/?pretty - register: result - until: result.status == 200 - retries: 60 - delay: 1 - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/elasticsearch/tests/0204_config.7.goss.yml b/roles/elasticsearch/tests/0204_config.7.goss.yml deleted file mode 100644 index f06754382..000000000 --- a/roles/elasticsearch/tests/0204_config.7.goss.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- - -file: - tmp/config/default/default.yml: - exists: true - filetype: file - owner: root - group: elasticsearch - mode: "0660" - contains: - - "cluster:" - - " name: foo" - - "path.data: /foo/bar" - tmp/config/default/default_deprecated.yml: - exists: true - filetype: file - owner: root - group: elasticsearch - mode: "0660" - contains: - - "cluster.name: foo" - - "path.data: /foo/bar" - tmp/config/default/default_content.yml: - exists: true - filetype: file - owner: root - group: elasticsearch - mode: "0660" - contains: - - "cluster:" - - " name: foo" - - "path.data: /foo/bar" - tmp/config/default/template.yml: - exists: true - filetype: file - owner: root - group: elasticsearch - mode: "0660" - contains: - - "cluster.name: foo" - - "path.data: /foo/bar" diff --git a/roles/elasticsearch/tests/0204_config.7.yml b/roles/elasticsearch/tests/0204_config.7.yml deleted file mode 100644 index 82d936a37..000000000 --- a/roles/elasticsearch/tests/0204_config.7.yml +++ /dev/null @@ -1,76 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/elasticsearch_7.yml - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['jessie'] - - apt: - name: "{{ { - 'jessie': 'openjdk-8-jre-headless', - 'stretch': 'openjdk-8-jre-headless', - 'buster': 'openjdk-11-jre-headless', - }[ansible_distribution_release] }}" - install_recommends: false - - - block: - - file: - path: tmp/config/default - state: "{{ item }}" - loop: [absent, directory] - # Default - - import_role: - # Play role fully on first run, so that handlers don't breaks - name: manala.elasticsearch - vars: - manala_elasticsearch_config_file: tmp/config/default/default.yml - manala_elasticsearch_config: - cluster: - name: foo - path.data: /foo/bar - # Default - Deprecated - - import_role: - name: manala.elasticsearch - tasks_from: config - vars: - manala_elasticsearch_config_file: tmp/config/default/default_deprecated.yml - manala_elasticsearch_config: - - cluster.name: foo - - path.data: /foo/bar - # Default - Content - - import_role: - name: manala.elasticsearch - tasks_from: config - vars: - manala_elasticsearch_config_file: tmp/config/default/default_content.yml - manala_elasticsearch_config: | - cluster: - name: foo - path.data: /foo/bar - # Template - - import_role: - name: manala.elasticsearch - tasks_from: config - vars: - manala_elasticsearch_config_file: tmp/config/default/template.yml - manala_elasticsearch_config_template: config/elasticsearch/elasticsearch.yml.j2 - manala_elasticsearch_config: - cluster: - name: foo - path: - data: /foo/bar - always: - - name: Wait for pretty response - uri: - url: http://localhost:9200/?pretty - register: result - until: result.status == 200 - retries: 60 - delay: 1 - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/elasticsearch/tests/0304_environment.7.goss.yml b/roles/elasticsearch/tests/0304_environment.7.goss.yml deleted file mode 100644 index 47979ac96..000000000 --- a/roles/elasticsearch/tests/0304_environment.7.goss.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- - -file: - tmp/environment/default/default: - exists: true - filetype: file - owner: root - group: elasticsearch - mode: "0660" - contains: - - "/^ES_JAVA_OPTS=\"-Xms1g -Xmx1g\"$/" - - "/^FOO=\"bar\"$/" - tmp/environment/default/default_deprecated: - exists: true - filetype: file - owner: root - group: elasticsearch - mode: "0660" - contains: - - "/^ES_JAVA_OPTS=\"-Xms1g -Xmx1g\"$/" - - "/^FOO=\"bar\"$/" - tmp/environment/default/default_content: - exists: true - filetype: file - owner: root - group: elasticsearch - mode: "0660" - contains: - - "/^ES_JAVA_OPTS=\"-Xms1g -Xmx1g\"$/" - - "/^FOO=\"bar\"$/" - tmp/environment/default/template: - exists: true - filetype: file - owner: root - group: elasticsearch - mode: "0660" - contains: - - "/^ES_JAVA_OPTS=\"-Xms1g -Xmx1g\"$/" - - "/^FOO=\"bar\"$/" - tmp/environment/default/template_deprecated: - exists: true - filetype: file - owner: root - group: elasticsearch - mode: "0660" - contains: - - "/^ES_JAVA_OPTS=\"-Xms1g -Xmx1g\"$/" - - "/^FOO=\"bar\"$/" diff --git a/roles/elasticsearch/tests/0304_environment.7.yml b/roles/elasticsearch/tests/0304_environment.7.yml deleted file mode 100644 index d23c5c0d0..000000000 --- a/roles/elasticsearch/tests/0304_environment.7.yml +++ /dev/null @@ -1,82 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/elasticsearch_7.yml - - import_tasks: pre_tasks/backports.yml - when: ansible_distribution_release in ['jessie'] - - apt: - name: "{{ { - 'jessie': 'openjdk-8-jre-headless', - 'stretch': 'openjdk-8-jre-headless', - 'buster': 'openjdk-11-jre-headless', - }[ansible_distribution_release] }}" - install_recommends: false - - - block: - - file: - path: tmp/environment/default - state: "{{ item }}" - loop: [absent, directory] - # Default - - import_role: - # Play role fully on first run, so that handlers don't breaks - name: manala.elasticsearch - vars: - manala_elasticsearch_environment_file: tmp/environment/default/default - manala_elasticsearch_environment: - ES_JAVA_OPTS: -Xms1g -Xmx1g - FOO: bar - # Default - Deprecated - - import_role: - name: manala.elasticsearch - tasks_from: environment - vars: - manala_elasticsearch_environment_file: tmp/environment/default/default_deprecated - manala_elasticsearch_environment: - - ES_JAVA_OPTS: -Xms1g -Xmx1g - - FOO: bar - # Default - Content - - import_role: - name: manala.elasticsearch - tasks_from: environment - vars: - manala_elasticsearch_environment_file: tmp/environment/default/default_content - manala_elasticsearch_environment: | - ES_JAVA_OPTS="-Xms1g -Xmx1g" - FOO="bar" - # Template - - import_role: - name: manala.elasticsearch - tasks_from: environment - vars: - manala_elasticsearch_environment_file: tmp/environment/default/template - manala_elasticsearch_environment_template: environment/elasticsearch/elasticsearch.j2 - manala_elasticsearch_environment: - ES_JAVA_OPTS: -Xms1g -Xmx1g - FOO: bar - # Template - Deprecated - - import_role: - name: manala.elasticsearch - tasks_from: environment - vars: - manala_elasticsearch_environment_file: tmp/environment/default/template_deprecated - manala_elasticsearch_environment_template: environment/empty.j2 - manala_elasticsearch_environment: - - ES_JAVA_OPTS: -Xms1g -Xmx1g - - FOO: bar - always: - - name: Wait for pretty response - uri: - url: http://localhost:9200/?pretty - register: result - until: result.status == 200 - retries: 60 - delay: 1 - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/elasticsearch/tests/pre_tasks/apt_keys/elasticsearch.pgp b/roles/elasticsearch/tests/pre_tasks/apt_keys/elasticsearch.pgp deleted file mode 100644 index cc7eea87e..000000000 --- a/roles/elasticsearch/tests/pre_tasks/apt_keys/elasticsearch.pgp +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- - -mQENBFI3HsoBCADXDtbNJnxbPqB1vDNtCsqhe49vFYsZN9IOZsZXgp7aHjh6CJBD -A+bGFOwyhbd7at35jQjWAw1O3cfYsKAmFy+Ar3LHCMkV3oZspJACTIgCrwnkic/9 -CUliQe324qvObU2QRtP4Fl0zWcfb/S8UYzWXWIFuJqMvE9MaRY1bwUBvzoqavLGZ -j3SF1SPO+TB5QrHkrQHBsmX+Jda6d4Ylt8/t6CvMwgQNlrlzIO9WT+YN6zS+sqHd -1YK/aY5qhoLNhp9G/HxhcSVCkLq8SStj1ZZ1S9juBPoXV1ZWNbxFNGwOh/NYGldD -2kmBf3YgCqeLzHahsAEpvAm8TBa7Q9W21C8vABEBAAG0RUVsYXN0aWNzZWFyY2gg -KEVsYXN0aWNzZWFyY2ggU2lnbmluZyBLZXkpIDxkZXZfb3BzQGVsYXN0aWNzZWFy -Y2gub3JnPokBOAQTAQIAIgUCUjceygIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgEC -F4AACgkQ0n1mbNiOQrRzjAgAlTUQ1mgo3nK6BGXbj4XAJvuZDG0HILiUt+pPnz75 -nsf0NWhqR4yGFlmpuctgCmTD+HzYtV9fp9qW/bwVuJCNtKXk3sdzYABY+Yl0Cez/ -7C2GuGCOlbn0luCNT9BxJnh4mC9h/cKI3y5jvZ7wavwe41teqG14V+EoFSn3NPKm -TxcDTFrV7SmVPxCBcQze00cJhprKxkuZMPPVqpBS+JfDQtzUQD/LSFfhHj9eD+Xe -8d7sw+XvxB2aN4gnTlRzjL1nTRp0h2/IOGkqYfIG9rWmSLNlxhB2t+c0RsjdGM4/ -eRlPWylFbVMc5pmDpItrkWSnzBfkmXL3vO2X3WvwmSFiQbkBDQRSNx7KAQgA5JUl -zcMW5/cuyZR8alSacKqhSbvoSqqbzHKcUQZmlzNMKGTABFG1yRx9r+wa/fvqP6OT -RzRDvVS/cycws8YX7Ddum7x8uI95b9ye1/Xy5noPEm8cD+hplnpU+PBQZJ5XJ2I+ -1l9Nixx47wPGXeClLqcdn0ayd+v+Rwf3/XUJrvccG2YZUiQ4jWZkoxsA07xx7Bj+ -Lt8/FKG7sHRFvePFU0ZS6JFx9GJqjSBbHRRkam+4emW3uWgVfZxuwcUCn1ayNgRt -KiFv9jQrg2TIWEvzYx9tywTCxc+FFMWAlbCzi+m4WD+QUWWfDQ009U/WM0ks0Kww -EwSk/UDuToxGnKU2dQARAQABiQEfBBgBAgAJBQJSNx7KAhsMAAoJENJ9ZmzYjkK0 -c3MIAIE9hAR20mqJWLcsxLtrRs6uNF1VrpB+4n/55QU7oxA1iVBO6IFu4qgsF12J -TavnJ5MLaETlggXY+zDef9syTPXoQctpzcaNVDmedwo1SiL03uMoblOvWpMR/Y0j -6rm7IgrMWUDXDPvoPGjMl2q1iTeyHkMZEyUJ8SKsaHh4jV9wp9KmC8C+9CwMukL7 -vM5w8cgvJoAwsp3Fn59AxWthN3XJYcnMfStkIuWgR7U2r+a210W6vnUxU4oN0PmM -cursYPyeV0NX/KQeUeNMwGTFB6QHS/anRaGQewijkrYYoTNtfllxIu9XYmiBERQ/ -qPDlGRlOgVTd9xUfHFkzB52c70E= -=92oX ------END PGP PUBLIC KEY BLOCK----- diff --git a/roles/elasticsearch/tests/pre_tasks/backports.yml b/roles/elasticsearch/tests/pre_tasks/backports.yml deleted file mode 100644 index 684fed79c..000000000 --- a/roles/elasticsearch/tests/pre_tasks/backports.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- - -# Jessie repositories have been archived, meaning that some of them -# (backports, for instance) will remain invalid forever. -- name: Pre tasks > Backports apt repository validity - copy: - dest: /etc/apt/apt.conf.d/archive - content: | - Acquire::Check-Valid-Until "false"; - when: ansible_distribution_release in ['jessie'] - -- name: Pre tasks > Backports apt repository - apt_repository: - repo: deb http://{{ (ansible_distribution_release in ['jessie'])|ternary('archive', 'deb') }}.debian.org/debian {{ ansible_distribution_release }}-backports main - -- name: Pre tasks > Backports java preferences - copy: - dest: /etc/apt/preferences.d/openjdk - content: | - Package: openjdk-* ca-certificates-java - Pin: release a={{ ansible_distribution_release }}-backports - Pin-Priority: 900 - when: ansible_distribution_release in ['jessie'] diff --git a/roles/elasticsearch/tests/pre_tasks/elasticsearch_1.7.yml b/roles/elasticsearch/tests/pre_tasks/elasticsearch_1.7.yml deleted file mode 100644 index 4ed331ca2..000000000 --- a/roles/elasticsearch/tests/pre_tasks/elasticsearch_1.7.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Pre tasks > Elasticsearch apt key - apt_key: - file: pre_tasks/apt_keys/elasticsearch.pgp - id: D88E42B4 - -- name: Pre tasks > Elasticsearch 1.7 apt repository - apt_repository: - repo: deb https://packages.elastic.co/elasticsearch/1.7/debian stable main diff --git a/roles/elasticsearch/tests/pre_tasks/elasticsearch_2.yml b/roles/elasticsearch/tests/pre_tasks/elasticsearch_2.yml deleted file mode 100644 index ae66b4ea8..000000000 --- a/roles/elasticsearch/tests/pre_tasks/elasticsearch_2.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Pre tasks > Elasticsearch apt key - apt_key: - file: pre_tasks/apt_keys/elasticsearch.pgp - id: D88E42B4 - -- name: Pre tasks > Elasticsearch 2 apt repository - apt_repository: - repo: deb https://packages.elastic.co/elasticsearch/2.x/debian stable main diff --git a/roles/elasticsearch/tests/pre_tasks/elasticsearch_5.yml b/roles/elasticsearch/tests/pre_tasks/elasticsearch_5.yml deleted file mode 100644 index 7073ff6ff..000000000 --- a/roles/elasticsearch/tests/pre_tasks/elasticsearch_5.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Pre tasks > Elasticsearch apt key - apt_key: - file: pre_tasks/apt_keys/elasticsearch.pgp - id: D88E42B4 - -- name: Pre tasks > Elasticsearch 5 apt repository - apt_repository: - repo: deb https://artifacts.elastic.co/packages/5.x/apt stable main diff --git a/roles/elasticsearch/tests/pre_tasks/elasticsearch_6.yml b/roles/elasticsearch/tests/pre_tasks/elasticsearch_6.yml deleted file mode 100644 index 461861716..000000000 --- a/roles/elasticsearch/tests/pre_tasks/elasticsearch_6.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Pre tasks > Elasticsearch apt key - apt_key: - file: pre_tasks/apt_keys/elasticsearch.pgp - id: D88E42B4 - -- name: Pre tasks > Elasticsearch 6 apt repository - apt_repository: - repo: deb https://artifacts.elastic.co/packages/6.x/apt stable main diff --git a/roles/elasticsearch/tests/pre_tasks/elasticsearch_7.yml b/roles/elasticsearch/tests/pre_tasks/elasticsearch_7.yml deleted file mode 100644 index 9dae6fc7c..000000000 --- a/roles/elasticsearch/tests/pre_tasks/elasticsearch_7.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Pre tasks > Elasticsearch apt key - apt_key: - file: pre_tasks/apt_keys/elasticsearch.pgp - id: D88E42B4 - -- name: Pre tasks > Elasticsearch 7 apt repository - apt_repository: - repo: deb https://artifacts.elastic.co/packages/7.x/apt stable main diff --git a/roles/elasticsearch/tests/tmp/.gitignore b/roles/elasticsearch/tests/tmp/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/roles/elasticsearch/tests/tmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/roles/environment/.gitignore b/roles/environment/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/environment/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/environment/.manala/make/Makefile b/roles/environment/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/environment/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/environment/.manala/make/Makefile.docker b/roles/environment/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/environment/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/environment/.manala/make/Makefile.host b/roles/environment/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/environment/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/environment/.manala/make/Makefile.manala b/roles/environment/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/environment/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/environment/.manala/make/Makefile.travis b/roles/environment/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/environment/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/environment/.manala/make/gmsl/__gmsl b/roles/environment/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/environment/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/environment/.manala/make/gmsl/gmsl b/roles/environment/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/environment/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/environment/.travis.yml b/roles/environment/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/environment/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/environment/CHANGELOG.md b/roles/environment/CHANGELOG.md deleted file mode 100644 index 764946556..000000000 --- a/roles/environment/CHANGELOG.md +++ /dev/null @@ -1,51 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.2] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.1] - 2019-11-29 -### Changed -- Update 'lookup' to use 'query' -- Minimum required version of ansible up to 2.5.0 - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.6] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.5] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.4] - 2018-06-05 -### Changed -- Replace deprecated uses of "include" - -## [1.0.3] - 2018-01-23 -### Fixed -- Support non-scalar variable intepretation only in legacy mode - -### Changed -- Alphabetically sort variables - -## [1.0.2] - 2017-12-14 -### Added -- Support variables as dict - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.0] - 2017-06-21 -### Added -- Handle variables diff --git a/roles/environment/Makefile b/roles/environment/Makefile deleted file mode 100644 index b44c407b9..000000000 --- a/roles/environment/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.environment -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/environment/README.md b/roles/environment/README.md index 9385900f4..6b3a49ffd 100644 --- a/roles/environment/README.md +++ b/roles/environment/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Environment [![Build Status](https://travis-ci.org/manala/ansible-role-environment.svg?branch=master)](https://travis-ci.org/manala/ansible-role-environment) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Environment This role will deal with the setup of environment variables. -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,26 +14,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.environment -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.environment -``` +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| ------------------------------ | ------- | ------- | ---------------------- | -| `manala_environment_files` | ['pam'] | Array | Environment files | -| `manala_environment_variables` | {}/[] | Array | Environment variables | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example @@ -63,30 +36,20 @@ manala_environment_variables: BAR: true ``` -For legacy purposes, `manala_environment_variables` also accepts values as -a dictionnary list. -Note that in this mode (and only in this mode), some non-scalar values are -interpreted to strings. - -```yaml -manala_environment_variables: - - FOO: bar - - FOO_NULL: ~ # -> "null" - - FOO_TRUE: true # -> "true" - - FOO_FALSE: false # -> "false" -``` - ## Example playbook ```yaml - hosts: servers - roles: - - { role: manala.environment } + tasks: + - import_role: + name: manala.roles.environment ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/environment/lookup_plugins/.gitignore b/roles/environment/lookup_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/environment/lookup_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/environment/lookup_plugins/manala_environment_files.py b/roles/environment/lookup_plugins/manala_environment_files.py deleted file mode 100644 index 897aabdc5..000000000 --- a/roles/environment/lookup_plugins/manala_environment_files.py +++ /dev/null @@ -1,51 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.module_utils.six import string_types -from ansible.errors import AnsibleError - -class LookupModule(LookupBase): - - def run(self, terms, variables=None, **kwargs): - - results = [] - - patterns = terms[1] - terms = terms[0] - - for term in self._flatten(terms): - - items = [] - - if isinstance(term, string_types): - # Pattern - if term not in patterns: - raise AnsibleError('"%s" is not a valid pattern' % (term)) - items.append({ - 'file': patterns.get(term).get('file'), - 'export': patterns.get(term).get('export', False) - }) - else: - # Must be a dict - if not isinstance(term, dict): - raise AnsibleError('Expect a dict') - # Expanded syntax - items.append({ - 'file': term.get('file'), - 'export': term.get('export', False) - }) - - - # Merge by index key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['file'] == item['file']: - results[i] = item - itemFound = True - break - if not itemFound: - results.append(item) - - return results diff --git a/roles/environment/lookup_plugins/manala_environment_variables.py b/roles/environment/lookup_plugins/manala_environment_variables.py deleted file mode 100644 index 4acb0fb2f..000000000 --- a/roles/environment/lookup_plugins/manala_environment_variables.py +++ /dev/null @@ -1,67 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.module_utils.six import string_types -from ansible.errors import AnsibleError - -class LookupModule(LookupBase): - - def legacy_format_value(self, value): - if (value is None): - return 'null' - elif (value is True): - return 'true' - elif (value is False): - return 'false' - else: - return value - - def run(self, terms, variables=None, **kwargs): - - results = [] - - if isinstance(terms[0], dict): - for name in sorted(terms[0]): - value = terms[0].get(name) - if not isinstance(value, (string_types, int, float)) or isinstance(value, bool): - raise AnsibleError("Expected a string, an integer or a float for key \"%s\" in manala_environment_variables" % name) - results.append({ - 'name': name, - 'value': value - }) - else: - # Legacy - for term in self._flatten(terms): - - # Term must be a dict - if not isinstance(term, dict): - raise AnsibleError('Expect a dict') - - items = [] - - if 'name' in term and 'value' in term: - # Expanded syntax - items.append({ - 'name': term.get('name'), - 'value': self.legacy_format_value(term.get('value')) - }) - else: - # Short syntax - items.append({ - 'name': list(term.keys())[0], - 'value': self.legacy_format_value(list(term.values())[0]) - }) - - # Merge by index key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['name'] == item['name']: - results[i] = item - itemFound = True - break - if not itemFound: - results.append(item) - - return results diff --git a/roles/environment/meta/main.yml b/roles/environment/meta/main.yml index 1806980f7..c48245cd7 100644 --- a/roles/environment/meta/main.yml +++ b/roles/environment/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: environment - author: Manala - company: Manala - description: Handle environment variables - license: MIT - min_ansible_version: 2.5.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: environment + author: Manala + company: Manala + description: Handle environment variables + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - environment diff --git a/roles/environment/tasks/variables.yml b/roles/environment/tasks/variables.yml index 7cc05f1cf..3d8b59f2d 100644 --- a/roles/environment/tasks/variables.yml +++ b/roles/environment/tasks/variables.yml @@ -4,12 +4,11 @@ blockinfile: dest: "{{ item.file }}" block: | - {% for variable in query('manala_environment_variables', manala_environment_variables) %} - {{ (item.export)|ternary('export ', '') }}{{ variable.name }}="{{ variable.value }}" + {% for key, value in manala_environment_variables.items() %} + {{ (item.export)|ternary('export ', '') }}{{ key }}="{{ value }}" {% endfor %} loop: "{{ query( - 'manala_environment_files', - manala_environment_files, - manala_environment_files_patterns - ) - }}" + 'manala.roles.environment_files', + manala_environment_files, + manala_environment_files_patterns + ) }}" diff --git a/roles/environment/tests/.gitignore b/roles/environment/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/environment/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/environment/tests/0100_variables.goss.yml b/roles/environment/tests/0100_variables.goss.yml deleted file mode 100644 index 3d5aa9838..000000000 --- a/roles/environment/tests/0100_variables.goss.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -file: - /etc/environment: - exists: true - filetype: file - contains: - - '_FOO="bar"' - - '_BAR="123"' - - 'BAR="123"' - - 'BAZ="1.2"' - - 'FOO="bar"' - - 'QUX="foo=bar"' - /etc/zsh/zshenv: - exists: true - filetype: file - contains: - - '# /etc/zsh/zshenv' - - 'export BAR="123"' - - 'export BAZ="1.2"' - - 'export FOO="bar"' - - 'export QUX="foo=bar"' - /etc/profile.d/test.sh: - exists: true - filetype: file - contains: - - '# /etc/profile.d/test.sh' - - 'export BAR="123"' - - 'export BAZ="1.2"' - - 'export FOO="bar"' - - 'export QUX="foo=bar"' diff --git a/roles/environment/tests/0100_variables.yml b/roles/environment/tests/0100_variables.yml deleted file mode 100644 index b610c416a..000000000 --- a/roles/environment/tests/0100_variables.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_environment_files: - - pam - - zsh - - file: /etc/profile.d/test.sh - export: true - manala_environment_variables: - FOO: bar - BAR: 123 - BAZ: 1.2 - QUX: foo=bar - pre_tasks: - - copy: - dest: /etc/environment - content: | - _FOO="bar" - _BAR="123" - - file: - path: /etc/zsh - state: directory - - copy: - dest: /etc/zsh/zshenv - content: | - # /etc/zsh/zshenv - - copy: - dest: /etc/profile.d/test.sh - content: | - # /etc/profile.d/test.sh - roles: - - manala.environment - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/environment/tests/0101_variables_legacy.goss.yml b/roles/environment/tests/0101_variables_legacy.goss.yml deleted file mode 100644 index a0d8bf4e4..000000000 --- a/roles/environment/tests/0101_variables_legacy.goss.yml +++ /dev/null @@ -1,40 +0,0 @@ ---- - -file: - /etc/environment: - exists: true - filetype: file - contains: - - '_FOO="bar"' - - '_BAR="123"' - - 'FOO="bar"' - - 'BAR="123"' - - 'BAZ="1.2"' - - 'QUX="foo=bar"' - - 'FOO_NULL="null"' - - 'FOO_TRUE="true"' - - 'FOO_FALSE="false"' - /etc/zsh/zshenv: - exists: true - filetype: file - contains: - - '# /etc/zsh/zshenv' - - 'export FOO="bar"' - - 'export BAR="123"' - - 'export BAZ="1.2"' - - 'export QUX="foo=bar"' - - 'export FOO_NULL="null"' - - 'export FOO_TRUE="true"' - - 'export FOO_FALSE="false"' - /etc/profile.d/test.sh: - exists: true - filetype: file - contains: - - '# /etc/profile.d/test.sh' - - 'export FOO="bar"' - - 'export BAR="123"' - - 'export BAZ="1.2"' - - 'export QUX="foo=bar"' - - 'export FOO_NULL="null"' - - 'export FOO_TRUE="true"' - - 'export FOO_FALSE="false"' diff --git a/roles/environment/tests/0101_variables_legacy.yml b/roles/environment/tests/0101_variables_legacy.yml deleted file mode 100644 index 473926d7d..000000000 --- a/roles/environment/tests/0101_variables_legacy.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_environment_files: - - pam - - zsh - - file: /etc/profile.d/test.sh - export: true - manala_environment_variables: - - FOO: bar - - BAR: 123 - - BAZ: 1.2 - - QUX: foo=bar - - FOO_NULL: null - - FOO_TRUE: true - - FOO_FALSE: false - pre_tasks: - - copy: - dest: /etc/environment - content: | - _FOO="bar" - _BAR="123" - - file: - path: /etc/zsh - state: directory - - copy: - dest: /etc/zsh/zshenv - content: | - # /etc/zsh/zshenv - - copy: - dest: /etc/profile.d/test.sh - content: | - # /etc/profile.d/test.sh - roles: - - manala.environment - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/environment/tests/0102_variables_single.goss.yml b/roles/environment/tests/0102_variables_single.goss.yml deleted file mode 100644 index 5855a4b18..000000000 --- a/roles/environment/tests/0102_variables_single.goss.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- - -file: - /etc/environment: - exists: true - filetype: file - contains: - - 'BAZ="baz"' - - 'FOO="bar"' - /etc/zsh/zshenv: - exists: true - filetype: file - contains: - - '# /etc/zsh/zshenv' - - 'export FOO="bar"' - /etc/profile.d/test.sh: - exists: true - filetype: file - contains: - - '# /etc/profile.d/test.sh' - - 'export FOO="bar"' diff --git a/roles/environment/tests/0102_variables_single.yml b/roles/environment/tests/0102_variables_single.yml deleted file mode 100644 index 3b1f2607d..000000000 --- a/roles/environment/tests/0102_variables_single.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_environment_files: - - pam - - zsh - - file: /etc/profile.d/test.sh - export: true - manala_environment_variables: - FOO: bar - pre_tasks: - - copy: - dest: /etc/environment - content: | - BAZ="baz" - FOO="foo" - - file: - path: /etc/zsh - state: directory - - copy: - dest: /etc/zsh/zshenv - content: | - # /etc/zsh/zshenv - - copy: - dest: /etc/profile.d/test.sh - content: | - # /etc/profile.d/test.sh - roles: - - manala.environment - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/environment/tests/0103_variables_single_legacy.goss.yml b/roles/environment/tests/0103_variables_single_legacy.goss.yml deleted file mode 100644 index 5855a4b18..000000000 --- a/roles/environment/tests/0103_variables_single_legacy.goss.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- - -file: - /etc/environment: - exists: true - filetype: file - contains: - - 'BAZ="baz"' - - 'FOO="bar"' - /etc/zsh/zshenv: - exists: true - filetype: file - contains: - - '# /etc/zsh/zshenv' - - 'export FOO="bar"' - /etc/profile.d/test.sh: - exists: true - filetype: file - contains: - - '# /etc/profile.d/test.sh' - - 'export FOO="bar"' diff --git a/roles/environment/tests/0103_variables_single_legacy.yml b/roles/environment/tests/0103_variables_single_legacy.yml deleted file mode 100644 index 1b6b0581b..000000000 --- a/roles/environment/tests/0103_variables_single_legacy.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_environment_files: - - pam - - zsh - - file: /etc/profile.d/test.sh - export: true - manala_environment_variables: - - FOO: bar - pre_tasks: - - copy: - dest: /etc/environment - content: | - BAZ="baz" - FOO="foo" - - file: - path: /etc/zsh - state: directory - - copy: - dest: /etc/zsh/zshenv - content: | - # /etc/zsh/zshenv - - copy: - dest: /etc/profile.d/test.sh - content: | - # /etc/profile.d/test.sh - roles: - - manala.environment - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/fail2ban/.gitignore b/roles/fail2ban/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/fail2ban/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/fail2ban/.manala/make/Makefile b/roles/fail2ban/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/fail2ban/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/fail2ban/.manala/make/Makefile.docker b/roles/fail2ban/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/fail2ban/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/fail2ban/.manala/make/Makefile.host b/roles/fail2ban/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/fail2ban/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/fail2ban/.manala/make/Makefile.manala b/roles/fail2ban/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/fail2ban/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/fail2ban/.manala/make/Makefile.travis b/roles/fail2ban/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/fail2ban/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/fail2ban/.manala/make/gmsl/__gmsl b/roles/fail2ban/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/fail2ban/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/fail2ban/.manala/make/gmsl/gmsl b/roles/fail2ban/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/fail2ban/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/fail2ban/.travis.yml b/roles/fail2ban/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/fail2ban/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/fail2ban/CHANGELOG.md b/roles/fail2ban/CHANGELOG.md deleted file mode 100644 index f95c1c0d1..000000000 --- a/roles/fail2ban/CHANGELOG.md +++ /dev/null @@ -1,45 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.2] - 2020-08-28 -### Changed -- Explicit file permissions - -## [2.0.1] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.4] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.3] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.2] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.0] - 2017-06-09 -### Added -- Handle installation -- Handle config -- Handle services diff --git a/roles/fail2ban/Makefile b/roles/fail2ban/Makefile deleted file mode 100644 index 724007148..000000000 --- a/roles/fail2ban/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.fail2ban -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/fail2ban/README.md b/roles/fail2ban/README.md index dca3137ff..c67d88c62 100644 --- a/roles/fail2ban/README.md +++ b/roles/fail2ban/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Fail2Ban [![Build Status](https://travis-ci.org/manala/ansible-role-fail2ban.svg?branch=master)](https://travis-ci.org/manala/ansible-role-fail2ban) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Fail2Ban This role will deal with the setup and config of [Fail2Ban](https://www.fail2ban.org/wiki/index.php/Main_Page). -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,56 +14,36 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.fail2ban -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.fail2ban -``` - -## Role Handlers - -| Name | Type | Description | -| ------------------ | ------- | ----------------------- | -| `fail2ban restart` | Service | Restart fail2ban server | +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| ------------------------------------------ | ----------------- | ------ | -------------------------------------- | -| `manala_fail2ban_install_packages` | ~ | Array | Dependency packages to install | -| `manala_fail2ban_install_packages_default` | ['fail2ban'] | Array | Default dependency packages to install | -| `manala_fail2ban_config_template` | 'config/empty.j2' | String | Main config template | -| `manala_fail2ban_config` | [] | Array | Main config | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration ```yaml -manala_fail2ban_config: - - DEFAULT: - - maxretry: 5 - - apache: - - enabled: true +manala_fail2ban_config: | + [DEFAULT] + maxretry = 5 + [apache] + enabled = true ``` ## Example playbook ```yaml - hosts: servers - roles: - - { role: manala.fail2ban } + tasks: + - import_role: + name: manala.roles.fail2ban ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/fail2ban/defaults/main.yml b/roles/fail2ban/defaults/main.yml index 0902823fc..5c91120a8 100644 --- a/roles/fail2ban/defaults/main.yml +++ b/roles/fail2ban/defaults/main.yml @@ -8,4 +8,4 @@ manala_fail2ban_install_packages_default: # Config manala_fail2ban_config_file: /etc/fail2ban/jail.local manala_fail2ban_config_template: ~ -manala_fail2ban_config: [] +manala_fail2ban_config: ~ diff --git a/roles/fail2ban/handlers/main.yml b/roles/fail2ban/handlers/main.yml index 89324fa8a..3aa9b8111 100644 --- a/roles/fail2ban/handlers/main.yml +++ b/roles/fail2ban/handlers/main.yml @@ -2,5 +2,7 @@ - name: fail2ban restart service: - name: fail2ban + name: "{{ item }}" state: restarted + loop: + - fail2ban diff --git a/roles/fail2ban/meta/main.yml b/roles/fail2ban/meta/main.yml index 6eb4f2403..a846d03c9 100644 --- a/roles/fail2ban/meta/main.yml +++ b/roles/fail2ban/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: fail2ban - author: Manala - company: Manala - description: Handle fail2ban - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: fail2ban + author: Manala + company: Manala + description: Handle fail2ban + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - security diff --git a/roles/fail2ban/tasks/config.yml b/roles/fail2ban/tasks/config.yml index 396ee2261..256b6e276 100644 --- a/roles/fail2ban/tasks/config.yml +++ b/roles/fail2ban/tasks/config.yml @@ -2,11 +2,12 @@ - name: config > Template template: - src: "{{ manala_fail2ban_config_template|ternary(manala_fail2ban_config_template, 'config/empty.j2') }}" + src: "{{ manala_fail2ban_config_template|default('config/_default.j2', true) }}" dest: "{{ manala_fail2ban_config_file }}" owner: root group: root mode: "0644" - when: (manala_fail2ban_config_template is not none) or (manala_fail2ban_config|length) + when: manala_fail2ban_config_template + or manala_fail2ban_config notify: - fail2ban restart diff --git a/roles/fail2ban/tasks/install.yml b/roles/fail2ban/tasks/install.yml index 3a3d8557c..c4409789c 100644 --- a/roles/fail2ban/tasks/install.yml +++ b/roles/fail2ban/tasks/install.yml @@ -2,7 +2,9 @@ - name: install > Packages apt: - name: "{{ manala_fail2ban_install_packages|default(manala_fail2ban_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_fail2ban_install_packages|default(manala_fail2ban_install_packages_default, True) }}" diff --git a/roles/fail2ban/tasks/services.yml b/roles/fail2ban/tasks/services.yml index a95e98a11..b365856c0 100644 --- a/roles/fail2ban/tasks/services.yml +++ b/roles/fail2ban/tasks/services.yml @@ -4,5 +4,5 @@ service: name: "{{ item }}" state: started - with_items: + loop: - fail2ban diff --git a/roles/fail2ban/templates/config/_default.j2 b/roles/fail2ban/templates/config/_default.j2 new file mode 100644 index 000000000..36a917b0d --- /dev/null +++ b/roles/fail2ban/templates/config/_default.j2 @@ -0,0 +1,3 @@ +{%- set config = manala_fail2ban_config -%} + +{{ config }} diff --git a/roles/fail2ban/templates/config/_macros.j2 b/roles/fail2ban/templates/config/_macros.j2 deleted file mode 100644 index 6e72f03b6..000000000 --- a/roles/fail2ban/templates/config/_macros.j2 +++ /dev/null @@ -1,64 +0,0 @@ -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }}{{ '\n' }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {%- if value is sequence and value is not string -%} - [{{ key }}]{{ '\n' }}{{ config(value, [], indent) }} - {%- else -%} - {{ _config_parameter_key(key)|indent(indent, true) }} = {{ _config_parameter_value(value) }} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - {{ key }} -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {%- if value is sameas none -%} - {%- elif value is sameas true -%} - true - {%- elif value is sameas false -%} - false - {%- elif value is string -%} - {{ value }} - {%- elif value is number -%} - {{ value }} - {%- endif -%} -{%- endmacro -%} diff --git a/roles/fail2ban/templates/config/empty.j2 b/roles/fail2ban/templates/config/empty.j2 deleted file mode 100644 index 7e777479c..000000000 --- a/roles/fail2ban/templates/config/empty.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{{ macros.config(manala_fail2ban_config) }} diff --git a/roles/fail2ban/tests/.gitignore b/roles/fail2ban/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/fail2ban/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/fail2ban/tests/0100_install.goss.yml b/roles/fail2ban/tests/0100_install.goss.yml deleted file mode 100644 index eca33bc29..000000000 --- a/roles/fail2ban/tests/0100_install.goss.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- - -package: - fail2ban: - installed: true diff --git a/roles/fail2ban/tests/0100_install.yml b/roles/fail2ban/tests/0100_install.yml deleted file mode 100644 index 7a0e71ab2..000000000 --- a/roles/fail2ban/tests/0100_install.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_fail2ban_config: - - ssh: - - enabled: false - roles: - - manala.fail2ban - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/fail2ban/tests/0200_configs.goss.yml b/roles/fail2ban/tests/0200_configs.goss.yml deleted file mode 100644 index 78e0f8672..000000000 --- a/roles/fail2ban/tests/0200_configs.goss.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- - -file: - /etc/fail2ban/jail.local: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "[DEFAULT]" - - "maxretry = 5" diff --git a/roles/fail2ban/tests/0200_configs.yml b/roles/fail2ban/tests/0200_configs.yml deleted file mode 100644 index 8e4a266a5..000000000 --- a/roles/fail2ban/tests/0200_configs.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_fail2ban_config: - - ssh: - - enabled: false - - DEFAULT: - - maxretry: 5 - roles: - - manala.fail2ban - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/fail2ban/tests/0300_services.goss.yml b/roles/fail2ban/tests/0300_services.goss.yml deleted file mode 100644 index faf98aba7..000000000 --- a/roles/fail2ban/tests/0300_services.goss.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- - -service: - fail2ban: - enabled: true - running: true diff --git a/roles/fail2ban/tests/0300_services.yml b/roles/fail2ban/tests/0300_services.yml deleted file mode 100644 index 278645351..000000000 --- a/roles/fail2ban/tests/0300_services.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - vars: - manala_fail2ban_config: "{{ - ( - ansible_distribution_release in ['jessie'] - )|ternary([{ - 'ssh': [{'enabled': false}] - }], [{ - 'ssh': [{'enabled': false}], - 'sshd': [{'enabled': false}] - }]) - }}" - roles: - - manala.fail2ban - post_tasks: - - name: Goss - command: goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/files/.gitignore b/roles/files/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/files/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/files/.manala/make/Makefile b/roles/files/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/files/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/files/.manala/make/Makefile.docker b/roles/files/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/files/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/files/.manala/make/Makefile.host b/roles/files/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/files/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/files/.manala/make/Makefile.manala b/roles/files/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/files/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/files/.manala/make/Makefile.travis b/roles/files/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/files/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/files/.manala/make/gmsl/__gmsl b/roles/files/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/files/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/files/.manala/make/gmsl/gmsl b/roles/files/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/files/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/files/.travis.yml b/roles/files/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/files/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/files/CHANGELOG.md b/roles/files/CHANGELOG.md deleted file mode 100644 index 9df6d1b09..000000000 --- a/roles/files/CHANGELOG.md +++ /dev/null @@ -1,84 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.7] - 2020-11-12 -### Fixed -- Pass `task_vars` to indentified sub modules in attributes plugin #2 - -## [2.0.6] - 2020-11-10 -### Fixed -- Pass `task_vars` to indentified sub modules in attributes plugin - -## [2.0.5] - 2020-11-09 -### Added -- `ignore` attribute state -- file parents flag -- file force flag -- directory parents flag -- directory force flag - -### Changed -- Flatten attributes array - -## [2.0.4] - 2020-08-26 -### Changed -- Explicit file permissions - -## [2.0.3] - 2020-07-06 -### Added -- Flag `force` for "link_directory" and "link_file" states -- A default can be provided without path, so that it applies to *all* path -- Flag `parents` to make parent directories as needed - -## [2.0.2] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.1] - 2019-11-29 -### Changed -- Update 'lookup' to use 'query' -- Minimum required version of ansible up to 2.5.0 - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.7] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.6] - 2019-08-29 -### Added -- Handle states for `copy`, `content` and `template` - -## [1.0.5] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.4] - 2018-07-02 -### Added -- Handle url unarchiving - -## [1.0.3] - 2018-06-05 -### Fixed -- Replace link_file "touch" step by a combination of an unforced empty copy and a classic file module. This offers the same behaviour to the linked file, but don't report it as changed each time the role is played - -### Changed -- Replace deprecated uses of "include" - -## [1.0.2] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.1] - 2017-09-25 -### Changes -- Fix tests - -## [1.0.0] - 2017-05-22 -### Added -- Handle attributes diff --git a/roles/files/Makefile b/roles/files/Makefile deleted file mode 100644 index 40896e360..000000000 --- a/roles/files/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.files -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/files/README.md b/roles/files/README.md index f7843a644..518684856 100644 --- a/roles/files/README.md +++ b/roles/files/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Files [![Build Status](https://travis-ci.org/manala/ansible-role-files.svg?branch=master)](https://travis-ci.org/manala/ansible-role-files) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Files This role will deal with the attributes of files. -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,26 +14,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.files -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.files -``` +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| ---------------------------------- | ------- | ------ | ------------------------- | -| `manala_files_attributes` | [] | Array | Files attributes | -| `manala_files_attributes_defaults` | [] | Array | Files attributes defaults | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example @@ -200,13 +173,16 @@ manala_files_attributes_defaults: ```yaml - hosts: all - roles: - - role: manala.files + tasks: + - import_role: + name: manala.roles.files ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/files/action_plugins/.gitignore b/roles/files/action_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/files/action_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/files/action_plugins/manala_files_attributes.py b/roles/files/action_plugins/manala_files_attributes.py deleted file mode 100644 index c098f8672..000000000 --- a/roles/files/action_plugins/manala_files_attributes.py +++ /dev/null @@ -1,249 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.action import ActionBase - -import os - - -class FailedException(Exception): - def __init__(self, result): - #self.message = message - self.result = result - - -class ActionModule(ActionBase): - - TRANSFERS_FILES = False - - def _run_module(self, name, args, task_args=[], task_vars={}): - # Relevant task args - for key in task_args: - if key in self._task.args: - args[key] = self._task.args[key] - # Action - if name in ['template', 'copy']: - task = self._task.copy() - task.args = args - action = self._shared_loader_obj.action_loader.get( - name, - task=task, - connection=self._connection, - play_context=self._play_context, - loader=self._loader, - templar=self._templar, - shared_loader_obj=self._shared_loader_obj) - result = action.run(task_vars=task_vars) - else: - result = self._execute_module( - module_name=name, - module_args=args, - task_vars=task_vars) - if result.get('failed'): - raise FailedException(result) - return result - - def run(self, tmp=None, task_vars=None): - if task_vars is None: - task_vars = dict() - - result = super(ActionModule, self).run(tmp, task_vars) - del tmp # tmp no longer has any effect - - path = self._task.args.get('path') - state = self._task.args.get('state', 'file') - - result['changed'] = False - result['diff'] = [] - - try: - - # Absent - if (state == 'absent' and ( - 'template' in self._task.args - or 'content' in self._task.args - or 'copy' in self._task.args)): - return self._run_module( - 'file', - {'path': path, 'state': 'absent'}, - task_vars=task_vars) - - # Parents - if (self._task.args.get('parents') and ( - 'template' in self._task.args - or 'content' in self._task.args - or state == 'link' - or state == 'file')): - parents_result = self._run_module( - 'file', - {'path': os.path.dirname(path), 'state': 'directory'}, - task_args=['owner', 'group', 'mode'], - task_vars=task_vars) - result['changed'] |= parents_result['changed'] - result['diff'] += [parents_result['diff']] - - ############ - # Template # - ############ - - if 'template' in self._task.args: - - # Template - template_result = self._run_module( - 'template', - {'dest': path, 'src': self._task.args.get('template')}, - task_args=['force', 'owner', 'group', 'mode'], - task_vars=task_vars) - result['changed'] |= template_result['changed'] - result['diff'] += template_result['diff'] - - ########### - # Content # - ########### - - elif 'content' in self._task.args: - - # Content - content_result = self._run_module( - 'copy', - {'dest': path, 'content': self._task.args.get('content')}, - task_args=['force', 'owner', 'group', 'mode'], - task_vars=task_vars) - result['changed'] |= content_result['changed'] - result['diff'] += content_result['diff'] - - ######## - # Copy # - ######## - - elif 'copy' in self._task.args: - - result = self._run_module( - 'copy', - {'dest': path, 'src': self._task.args.get('copy')}, - task_args=['force', 'owner', 'group', 'mode'], - task_vars=task_vars) - - ####### - # Url # - ####### - - elif 'url' in self._task.args: - - # Url - url_result = self._run_module( - 'get_url', - {'dest': path, 'url': self._task.args.get('url')}, - task_args=['validate_certs', 'force', 'owner', 'group', 'mode'], - task_vars=task_vars) - result['changed'] |= url_result['changed'] - - # Unarchive - if self._task.args.get('unarchive', False) and not self._play_context.check_mode: - unarchive_result = self._run_module( - 'unarchive', - {'src': path, 'dest': os.path.dirname(path), 'remote_src': True}, - task_args=['creates'], - task_vars=task_vars) - - ######## - # Link # - ######## - - elif state == 'link': - - # Force - if self._task.args.get('force'): - link_stat = self._execute_remote_stat(path, task_vars, follow=False) - - if link_stat['exists'] and not link_stat['islnk']: - absent_result = self._run_module( - 'file', - {'path': path, 'state': 'absent'}, - task_vars=task_vars) - result['changed'] |= absent_result['changed'] - result['diff'] += [absent_result['diff']] - - # Link - link_result = self._run_module( - 'file', - {'path': path, 'src': self._task.args.get('src'), 'state': 'link'}, - task_args=['owner', 'group'], - task_vars=task_vars) - result['changed'] |= link_result['changed'] - result['diff'] += link_result['diff'] - - ############# - # Directory # - ############# - - elif state == 'directory': - - # Force - if self._task.args.get('force'): - link_stat = self._execute_remote_stat(path, task_vars, follow=True) - - if link_stat['exists'] and not link_stat['isdir']: - absent_result = self._run_module( - 'file', - {'path': path, 'state': 'absent'}, - task_vars=task_vars) - result['changed'] |= absent_result['changed'] - result['diff'] += [absent_result['diff']] - - # Directory - directory_result = self._run_module( - 'file', - {'path': path, 'state': 'directory'}, - task_args=['owner', 'group', 'mode'], - task_vars=task_vars) - result['changed'] |= directory_result['changed'] - result['diff'] += directory_result['diff'] - - ######## - # File # - ######## - - elif state == 'file': - - # Force - if self._task.args.get('force'): - link_stat = self._execute_remote_stat(path, task_vars, follow=True) - - if link_stat['exists'] and not link_stat['isreg']: - absent_result = self._run_module( - 'file', - {'path': path, 'state': 'absent'}, - task_vars=task_vars) - result['changed'] |= absent_result['changed'] - result['diff'] += [absent_result['diff']] - - # Create - create_result = self._run_module( - 'copy', - {'dest': path, 'content': '', 'force': False}, - task_args=['owner', 'group', 'mode']) - result['changed'] |= create_result['changed'] - - # File - file_result = self._run_module( - 'file', - {'path': path, 'state': 'file'}, - task_args=['owner', 'group', 'mode'], - task_vars=task_vars) - result['changed'] |= file_result['changed'] - result['diff'] += file_result['diff'] - - # Other... - else: - - result = self._run_module( - 'file', - {'path': path}, - task_args=['state', 'follow', 'recurse', 'src', 'force', 'owner', 'group', 'mode'], - task_vars=task_vars) - - return result - - except FailedException as failed: - return failed.result diff --git a/roles/files/lookup_plugins/.gitignore b/roles/files/lookup_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/files/lookup_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/files/lookup_plugins/manala_files_attributes.py b/roles/files/lookup_plugins/manala_files_attributes.py deleted file mode 100644 index 2e0be11c8..000000000 --- a/roles/files/lookup_plugins/manala_files_attributes.py +++ /dev/null @@ -1,94 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.errors import AnsibleError - -import re - - -class LookupModule(LookupBase): - - def _recursive_flatten(self, terms): - if not isinstance(terms, list): - raise AnsibleError('Expect a list but was a %s' % type(terms)) - ret = [] - for term in terms: - if isinstance(term, (list, tuple)): - ret.extend( - self._recursive_flatten(term) - ) - else: - ret.append(term) - return ret - - def _default(self, defaults, path): - result = {} - for default in defaults: - if ('path' not in default) or (re.search(default['path'], path)): - result.update(default) - return result - - def run(self, terms, variables=None, **kwargs): - - results = [] - - attributes = self._recursive_flatten(terms[0]) - defaults = self._flatten(terms[1]) - - itemDefault = {} - - for attribute in attributes: - - items = [] - - # Must be a dict - if not isinstance(attribute, dict): - raise AnsibleError('Expect a dict but was a %s' % type(attribute)) - - # Check path key - if 'path' not in attribute: - raise AnsibleError('Expect a "path" key') - - state = attribute.get('state') - - # Ignore - if state == 'ignore': - continue - - # Composite link - if state in ['link_directory', 'link_file']: - if 'src' not in attribute: - raise AnsibleError('Expect "src" key') - - # Composite - item = itemDefault.copy() - item.update(self._default(defaults, attribute['src'])) - item.update(attribute) - item.update({ - 'path': item.pop('src'), - 'state': state.split('_')[1] - }) - items.append(item) - - # Link - attribute['state'] = 'link' - - item = itemDefault.copy() - item.update(self._default(defaults, attribute['path'])) - item.update(attribute) - items.append(item) - - # Merge by path key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['path'] == item['path']: - results[i] = item - itemFound = True - break - - if not itemFound: - results.append(item) - - return results diff --git a/roles/files/meta/main.yml b/roles/files/meta/main.yml index 48fa8ad22..d59768fc5 100644 --- a/roles/files/meta/main.yml +++ b/roles/files/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: files - author: Manala - company: Manala - description: Handle files attributes - license: MIT - min_ansible_version: 2.5.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: files + author: Manala + company: Manala + description: Handle files attributes + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - files diff --git a/roles/files/tasks/attributes.yml b/roles/files/tasks/attributes.yml index efa69b2c4..aeb2513af 100644 --- a/roles/files/tasks/attributes.yml +++ b/roles/files/tasks/attributes.yml @@ -1,7 +1,7 @@ --- - name: attributes - manala_files_attributes: + manala.roles.files_attributes: path: "{{ item.path }}" state: "{{ item.state|default(omit) }}" parents: "{{ item.parents|default(omit) }}" @@ -20,7 +20,7 @@ group: "{{ item.group|default(omit) }}" mode: "{{ item.mode|default(omit) }}" loop: "{{ query( - 'manala_files_attributes', - manala_files_attributes, - manala_files_attributes_defaults + 'manala.roles.files_attributes', + manala_files_attributes, + manala_files_attributes_defaults ) }}" diff --git a/roles/files/tests/.gitignore b/roles/files/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/files/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/files/tests/0000_default.goss.yml b/roles/files/tests/0000_default.goss.yml deleted file mode 100644 index f6c468a45..000000000 --- a/roles/files/tests/0000_default.goss.yml +++ /dev/null @@ -1,355 +0,0 @@ ---- - -# Defaults -{{ if has "defaults" .Vars.tags }} -file: - /tmp/defaults/root: - exists: true - filetype: file - owner: root - group: root - /tmp/defaults/nobody: - exists: true - filetype: file - owner: nobody - group: nogroup - /tmp/defaults/mail: - exists: true - filetype: file - owner: mail - group: mail -{{ end }} - -# File -{{ if has "file" .Vars.tags }} -file: - # Default - /tmp/file/default/default: - exists: true - filetype: file - # Parents - /tmp/file/parents: - exists: true - filetype: directory - /tmp/file/parents/file: - exists: true - filetype: file - /tmp/file/parents_defaults: - exists: true - filetype: directory - /tmp/file/parents_defaults/file: - exists: true - filetype: file - /tmp/file/parents_unexisting/file: - exists: false - # File already exists as empty directory - /tmp/file/file_directory_empty/file_force: - exists: true - filetype: file - /tmp/file/file_directory_empty/file: - exists: true - filetype: directory - # File already exists as full directory - /tmp/file/file_directory_full/file_force: - exists: true - filetype: file - /tmp/file/file_directory_full/file: - exists: true - filetype: directory - # File already exists as link to file - /tmp/file/file_link_file/file_force: - exists: true - filetype: symlink - linked-to: /tmp/file/file_link_file/link_file - /tmp/file/file_link_file/file: - exists: true - filetype: symlink - linked-to: /tmp/file/file_link_file/link_file - # File already exists as link to directory - /tmp/file/file_link_directory/file_force: - exists: true - filetype: file - /tmp/file/file_link_directory/file: - exists: true - filetype: symlink - linked-to: /tmp/file/file_link_directory/link_file -{{ end }} - -# Link -{{ if has "link" .Vars.tags }} -file: - # Default - Link to file - /tmp/link/default/link_file: - exists: true - filetype: symlink - linked-to: /tmp/link/file - # Default - Link to link to file - /tmp/link/default/link_link_file: - exists: true - filetype: symlink - linked-to: /tmp/link/default/link_file - # Default - Link to directory - /tmp/link/default/link_directory: - exists: true - filetype: symlink - linked-to: /tmp/link/directory - # Default - Link to link to directory - /tmp/link/default/link_link_directory: - exists: true - filetype: symlink - linked-to: /tmp/link/default/link_directory - # Parents - /tmp/link/parents: - exists: true - filetype: directory - /tmp/link/parents/link: - exists: true - filetype: symlink - linked-to: /tmp/link/file - /tmp/link/parents_defaults: - exists: true - filetype: directory - /tmp/link/parents_defaults/link: - exists: true - filetype: symlink - linked-to: /tmp/link/file - /tmp/link/parents_unexisting/link: - exists: false - # Wrong - /tmp/link/wrong/link: - exists: true - filetype: symlink - linked-to: /tmp/link/directory - # Link already exists as file - /tmp/link/link_file/link_force: - exists: true - filetype: symlink - linked-to: /tmp/link/file - /tmp/link/link_file/link: - exists: true - filetype: file - # Link already exists as empty directory - /tmp/link/link_directory_empty/link_force: - exists: true - filetype: symlink - linked-to: /tmp/link/file - /tmp/link/link_directory_empty/link: - exists: true - filetype: directory - # Link already exists as full directory - /tmp/link/link_directory_full/link_force: - exists: true - filetype: symlink - linked-to: /tmp/link/file - /tmp/link/link_directory_full/link: - exists: true - filetype: directory -{{ end }} - -# Directory -{{ if has "directory" .Vars.tags }} -file: - # Default - /tmp/directory/default/default: - exists: true - filetype: directory - # Directory already exists as file - /tmp/directory/directory_file/directory_force: - exists: true - filetype: directory - /tmp/directory/directory_file/directory: - exists: true - filetype: file - # Directory already exists as link to file - /tmp/directory/directory_link_file/directory_force: - exists: true - filetype: directory - /tmp/directory/directory_link_file/directory: - exists: true - filetype: symlink - linked-to: /tmp/directory/directory_link_file/link_file - # Directory already exists as link to directory - /tmp/directory/directory_link_directory/directory_force: - exists: true - filetype: symlink - linked-to: /tmp/directory/directory_link_directory/link_directory - /tmp/directory/directory_link_directory/directory: - exists: true - filetype: symlink - linked-to: /tmp/directory/directory_link_directory/link_directory -{{ end }} - -# Copy -{{ if has "copy" .Vars.tags }} -file: - # Default - tmp/copy/default/default: - exists: true - filetype: file - contains: - - Copy default - tmp/copy/default/present: - exists: true - filetype: file - contains: - - Copy present - tmp/copy/default/absent: - exists: false - tmp/copy/default/ignore: - exists: false -{{ end }} - -# Url -{{ if has "url" .Vars.tags }} -file: - # Default - /tmp/url/default/humans.txt: - exists: true - filetype: file - contains: - - TEAM - - THANKS - - SITE - /tmp/url/default/alt-galaxy.tar.xz: - exists: true - filetype: file - /tmp/url/default/alt-galaxy: - exists: true - filetype: file -{{ end }} - -# Content -{{ if has "content" .Vars.tags }} -file: - # Default - tmp/content/default/default: - exists: true - filetype: file - contains: - - Content default - tmp/content/default/present: - exists: true - filetype: file - contains: - - Content present - tmp/content/default/absent: - exists: false - tmp/content/default/ignore: - exists: false - # Parents - tmp/content/parents: - exists: true - filetype: directory - tmp/content/parents/content: - exists: true - filetype: file - contains: - - Content parents default - tmp/content/parents_defaults: - exists: true - filetype: directory - tmp/content/parents_defaults/content: - exists: true - filetype: file - contains: - - Content defaults parents - tmp/content/parents_unexisting/content: - exists: false -{{ end }} - -# Template -{{ if has "template" .Vars.tags }} -file: - # Default - tmp/template/default/default: - exists: true - filetype: file - contains: - - Template default - tmp/template/default/present: - exists: true - filetype: file - contains: - - Template present - tmp/template/default/absent: - exists: false - tmp/template/default/ignore: - exists: false - # Parents - tmp/template/parents: - exists: true - filetype: directory - tmp/template/parents/template: - exists: true - filetype: file - contains: - - Template default - tmp/template/parents_defaults: - exists: true - filetype: directory - tmp/template/parents_defaults/template: - exists: true - filetype: file - contains: - - Template default - tmp/template/parents_unexisting/template: - exists: false -{{ end }} - -# Link directory -{{ if has "link_directory" .Vars.tags }} -file: - # Default - Default - /tmp/link_directory/default/link_directory: - exists: true - filetype: symlink - linked-to: /tmp/link_directory/default/directory - /tmp/link_directory/default/directory: - exists: true - filetype: directory - # Default - Sub directory - /tmp/link_directory/default/link_directory_sub: - exists: true - filetype: symlink - linked-to: /tmp/link_directory/default/directory_sub/directory - /tmp/link_directory/default/directory_sub/directory: - exists: true - filetype: directory - # Default - Permissions - /tmp/link_directory/default/link_permissions: - exists: true - filetype: symlink - linked-to: /tmp/link_directory/default/directory_permissions - owner: backup - group: games - /tmp/link_directory/default/directory_permissions: - exists: true - filetype: directory - owner: backup - group: games -{{ end }} - -# Link file -{{ if has "link_file" .Vars.tags }} -file: - # Default - Default - /tmp/link_file/default/link_file: - exists: true - filetype: symlink - linked-to: /tmp/link_file/default/file - /tmp/link_file/default/file: - exists: true - filetype: file - # Default - Permissions - /tmp/link_file/default/link_permissions: - exists: true - filetype: symlink - linked-to: /tmp/link_file/default/file_permissions - owner: backup - group: games - /tmp/link_file/default/file_permissions: - exists: true - filetype: file - owner: backup - group: games -{{ end }} diff --git a/roles/files/tests/0000_default.yml b/roles/files/tests/0000_default.yml deleted file mode 100644 index 3cba18d34..000000000 --- a/roles/files/tests/0000_default.yml +++ /dev/null @@ -1,714 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - gather_facts: false - tasks: - - ############ - # Defaults # - ############ - - - tags: [defaults] - block: - - file: - path: /tmp/defaults - state: "{{ item }}" - loop: [absent, directory] - - import_role: - name: manala.files - vars: - manala_files_attributes_defaults: - - user: nobody - - path: ^/tmp/defaults/root - user: root - group: root - - path: ^/tmp/defaults/nobody - group: nogroup - - path: ^/tmp/defaults/mail - user: mail - group: mail - manala_files_attributes: - - path: /tmp/defaults/root - state: touch - # Flatten - - - - path: /tmp/defaults/nobody - state: touch - - path: /tmp/defaults/mail - state: touch - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [defaults]}" validate - - ######## - # File # - ######## - - - tags: [file] - block: - - file: - path: /tmp/file - state: "{{ item }}" - loop: [absent, directory] - # Default - - block: - - file: - path: /tmp/file/default - state: directory - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/file/default/default - # Parents - - block: - - import_role: - name: manala.files - vars: - manala_files_attributes_defaults: - - path: ^/tmp/file/parents_defaults - parents: true - manala_files_attributes: - - path: /tmp/file/parents/file - parents: true - - path: /tmp/file/parents_defaults/file - - path: /tmp/file/parents_unexisting/file - rescue: - - debug: - msg: A planned error has been caught... - # File already exists as empty directory - - block: - - file: - path: /tmp/file/file_directory_empty - state: directory - - file: - path: "{{ item }}" - state: directory - loop: - - /tmp/file/file_directory_empty/file_force - - /tmp/file/file_directory_empty/file - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/file/file_directory_empty/file_force - force: true - - path: /tmp/file/file_directory_empty/file - rescue: - - debug: - msg: A planned error has been caught... - # File already exists as full directory - - block: - - file: - path: /tmp/file/file_directory_full - state: directory - - file: - path: "{{ item }}" - state: directory - loop: - - /tmp/file/file_directory_full/file_force - - /tmp/file/file_directory_full/file - - file: - path: "{{ item }}" - state: touch - loop: - - /tmp/file/file_directory_full/file_force/file - - /tmp/file/file_directory_full/file/file - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/file/file_directory_full/file_force - force: true - - path: /tmp/file/file_directory_full/file - rescue: - - debug: - msg: A planned error has been caught... - # File already exists as link to file - - block: - - file: - path: /tmp/file/file_link_file - state: directory - - file: - path: /tmp/file/file_link_file/link_file - state: touch - - file: - path: "{{ item }}" - src: /tmp/file/file_link_file/link_file - state: link - loop: - - /tmp/file/file_link_file/file_force - - /tmp/file/file_link_file/file - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/file/file_link_file/file_force - force: true - - path: /tmp/file/file_link_file/file - # File already exists as link to directory - - block: - - file: - path: /tmp/file/file_link_directory - state: directory - - file: - path: /tmp/file/file_link_directory/link_file - state: directory - - file: - path: "{{ item }}" - src: /tmp/file/file_link_directory/link_file - state: link - loop: - - /tmp/file/file_link_directory/file_force - - /tmp/file/file_link_directory/file - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/file/file_link_directory/file_force - force: true - - path: /tmp/file/file_link_directory/file - rescue: - - debug: - msg: A planned error has been caught... - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [file]}" validate - - ######## - # Link # - ######## - - - tags: [link] - block: - - file: - path: /tmp/link - state: "{{ item }}" - loop: [absent, directory] - - file: - path: /tmp/link/file - state: touch - - file: - path: /tmp/link/directory - state: directory - # Default - - block: - - file: - path: /tmp/link/default - state: directory - - import_role: - name: manala.files - vars: - manala_files_attributes: - # Link to file - - path: /tmp/link/default/link_file - src: /tmp/link/file - state: link - # Link to link to file - - path: /tmp/link/default/link_link_file - src: /tmp/link/default/link_file - state: link - # Flatten - - - # Link to directory - - path: /tmp/link/default/link_directory - src: /tmp/link/directory - state: link - # Link to link to directory - - path: /tmp/link/default/link_link_directory - src: /tmp/link/default/link_directory - state: link - # Parents - - block: - - import_role: - name: manala.files - vars: - manala_files_attributes_defaults: - - path: ^/tmp/link/parents_defaults - parents: true - manala_files_attributes: - - path: /tmp/link/parents/link - src: /tmp/link/file - state: link - parents: true - - path: /tmp/link/parents_defaults/link - src: /tmp/link/file - state: link - - path: /tmp/link/parents_unexisting/link - src: /tmp/link/file - state: link_directory - rescue: - - debug: - msg: A planned error has been caught... - # Wrong - - block: - - file: - path: /tmp/link/wrong - state: directory - - file: - path: /tmp/link/wrong/link - src: /tmp/link/file - state: link - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/link/wrong/link - src: /tmp/link/directory - state: link - # Link already exists as file - - block: - - file: - path: /tmp/link/link_file - state: directory - - file: - path: "{{ item }}" - state: touch - loop: - - /tmp/link/link_file/link_force - - /tmp/link/link_file/link - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/link/link_file/link_force - src: /tmp/link/file - state: link - force: true - - path: /tmp/link/link_file/link - src: /tmp/link/file - state: link - rescue: - - debug: - msg: A planned error has been caught... - # Link already exists as empty directory - - block: - - file: - path: /tmp/link/link_directory_empty - state: directory - - file: - path: "{{ item }}" - state: directory - loop: - - /tmp/link/link_directory_empty/link_force - - /tmp/link/link_directory_empty/link - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/link/link_directory_empty/link_force - src: /tmp/link/file - state: link - force: true - - path: /tmp/link/link_directory_empty/link - src: /tmp/link/file - state: link - rescue: - - debug: - msg: A planned error has been caught... - # Link already exists as full directory - - block: - - file: - path: /tmp/link/link_directory_full - state: directory - - file: - path: "{{ item }}" - state: directory - loop: - - /tmp/link/link_directory_full/link_force - - /tmp/link/link_directory_full/link - - file: - path: "{{ item }}" - state: touch - loop: - - /tmp/link/link_directory_full/link_force/file - - /tmp/link/link_directory_full/link/file - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/link/link_directory_full/link_force - src: /tmp/link/file - state: link - force: true - - path: /tmp/link/link_directory_full/link - src: /tmp/link/file - state: link - rescue: - - debug: - msg: A planned error has been caught... - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [link]}" validate - - ############# - # Directory # - ############# - - - tags: [directory] - block: - - file: - path: /tmp/directory - state: "{{ item }}" - loop: [absent, directory] - # Default - - block: - - file: - path: /tmp/directory/default - state: directory - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/directory/default/default - state: directory - # Directory already exists as file - - block: - - file: - path: /tmp/directory/directory_file - state: directory - - file: - path: "{{ item }}" - state: touch - loop: - - /tmp/directory/directory_file/directory_force - - /tmp/directory/directory_file/directory - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/directory/directory_file/directory_force - state: directory - force: true - - path: /tmp/directory/directory_file/directory - state: directory - rescue: - - debug: - msg: A planned error has been caught... - # Directory already exists as link to file - - block: - - file: - path: /tmp/directory/directory_link_file - state: directory - - file: - path: /tmp/directory/directory_link_file/link_file - state: touch - - file: - path: "{{ item }}" - src: /tmp/directory/directory_link_file/link_file - state: link - loop: - - /tmp/directory/directory_link_file/directory_force - - /tmp/directory/directory_link_file/directory - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/directory/directory_link_file/directory_force - state: directory - force: true - - path: /tmp/directory/directory_link_file/directory - state: directory - rescue: - - debug: - msg: A planned error has been caught... - # Directory already exists as link to directory - - block: - - file: - path: /tmp/directory/directory_link_directory - state: directory - - file: - path: /tmp/directory/directory_link_directory/link_directory - state: directory - - file: - path: "{{ item }}" - src: /tmp/directory/directory_link_directory/link_directory - state: link - loop: - - /tmp/directory/directory_link_directory/directory_force - - /tmp/directory/directory_link_directory/directory - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/directory/directory_link_directory/directory_force - state: directory - force: true - - path: /tmp/directory/directory_link_directory/directory - state: directory - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [directory]}" validate - - ######## - # Copy # - ######## - - - tags: [copy] - block: - - file: - path: tmp/copy - state: "{{ item }}" - loop: [absent, directory] - # Default - - block: - - file: - path: tmp/copy/default - state: directory - - file: - path: "{{ item }}" - state: touch - loop: - - tmp/copy/default/absent - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: tmp/copy/default/default - copy: fixtures/copy/default - # Flatten - - - - path: tmp/copy/default/present - copy: fixtures/copy/present - state: present - - path: tmp/copy/default/absent - state: absent - - path: tmp/copy/default/ignore - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [copy]}" validate - - ####### - # Url # - ####### - - - tags: [url] - block: - - file: - path: /tmp/url - state: "{{ item }}" - loop: [absent, directory] - # Default - - block: - - file: - path: /tmp/url/default - state: directory - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: /tmp/url/default/humans.txt - url: http://humanstxt.org/humans.txt - # Flatten - - - - path: /tmp/url/default/alt-galaxy.tar.xz - url: https://github.com/gantsign/alt-galaxy/releases/download/1.4.0/alt-galaxy_linux_amd64.tar.xz - unarchive: true - creates: /tmp/url/default/alt-galaxy - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [url]}" validate - - ########### - # Content # - ########### - - - tags: [content] - block: - - file: - path: tmp/content - state: "{{ item }}" - loop: [absent, directory] - # Default - - block: - - file: - path: tmp/content/default - state: directory - - file: - path: "{{ item }}" - state: touch - loop: - - tmp/content/default/absent - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: tmp/content/default/default - content: | - Content default - # Flatten - - - - path: tmp/content/default/present - content: | - Content present - state: present - - path: tmp/content/default/absent - state: absent - - path: tmp/content/default/ignore - state: ignore - # Parents - - block: - - import_role: - name: manala.files - vars: - manala_files_attributes_defaults: - - path: ^tmp/content/parents_defaults - parents: true - manala_files_attributes: - - path: tmp/content/parents/content - content: | - Content parents default - parents: true - - path: tmp/content/parents_defaults/content - content: | - Content defaults parents - - path: tmp/content/parents_unexisting/content - content: | - Content defaults parents - rescue: - - debug: - msg: A planned error has been caught... - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [content]}" validate - - ############ - # Template # - ############ - - - tags: [template] - block: - - file: - path: tmp/template - state: "{{ item }}" - loop: [absent, directory] - # Default - - block: - - file: - path: tmp/template/default - state: directory - - file: - path: "{{ item }}" - state: touch - loop: - - tmp/template/default/absent - - import_role: - name: manala.files - vars: - manala_files_attributes: - - path: tmp/template/default/default - template: fixtures/template/default.j2 - # Flatten - - - - path: tmp/template/default/present - template: fixtures/template/present.j2 - state: present - - path: tmp/template/default/absent - state: absent - - path: tmp/template/default/ignore - state: ignore - # Parents - - block: - - import_role: - name: manala.files - vars: - manala_files_attributes_defaults: - - path: ^tmp/template/parents_defaults - parents: true - manala_files_attributes: - - path: tmp/template/parents/template - template: fixtures/template/default.j2 - parents: true - - path: tmp/template/parents_defaults/template - template: fixtures/template/default.j2 - - path: tmp/template/parents_unexisting/template - template: fixtures/template/default.j2 - rescue: - - debug: - msg: A planned error has been caught... - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [template]}" validate - - ################## - # Link directory # - ################## - - - tags: [link_directory] - block: - - file: - path: /tmp/link_directory - state: "{{ item }}" - loop: [absent, directory] - # Default - - block: - - file: - path: /tmp/link_directory/default - state: directory - - import_role: - name: manala.files - vars: - manala_files_attributes: - # Default - - path: /tmp/link_directory/default/link_directory - src: /tmp/link_directory/default/directory - state: link_directory - # Sub directory - - path: /tmp/link_directory/default/link_directory_sub - src: /tmp/link_directory/default/directory_sub/directory - state: link_directory - # Permissions - - path: /tmp/link_directory/default/link_permissions - src: /tmp/link_directory/default/directory_permissions - state: link_directory - user: backup - group: games - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [link_directory]}" validate - - ############# - # Link file # - ############# - - - tags: [link_file] - block: - - file: - path: /tmp/link_file - state: "{{ item }}" - loop: [absent, directory] - # Default - - block: - - file: - path: /tmp/link_file/default - state: directory - - import_role: - name: manala.files - vars: - manala_files_attributes: - # Default - - path: /tmp/link_file/default/link_file - src: /tmp/link_file/default/file - state: link_file - # Permissions - - path: /tmp/link_file/default/link_permissions - src: /tmp/link_file/default/file_permissions - state: link_file - user: backup - group: games - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [link_file]}" validate diff --git a/roles/files/tests/fixtures/copy/default b/roles/files/tests/fixtures/copy/default deleted file mode 100644 index bbe120a66..000000000 --- a/roles/files/tests/fixtures/copy/default +++ /dev/null @@ -1 +0,0 @@ -Copy default diff --git a/roles/files/tests/fixtures/copy/present b/roles/files/tests/fixtures/copy/present deleted file mode 100644 index 85f00f779..000000000 --- a/roles/files/tests/fixtures/copy/present +++ /dev/null @@ -1 +0,0 @@ -Copy present diff --git a/roles/files/tests/fixtures/template/default.j2 b/roles/files/tests/fixtures/template/default.j2 deleted file mode 100644 index b5ea8a8e1..000000000 --- a/roles/files/tests/fixtures/template/default.j2 +++ /dev/null @@ -1 +0,0 @@ -Template {{ 'default' }} diff --git a/roles/files/tests/fixtures/template/present.j2 b/roles/files/tests/fixtures/template/present.j2 deleted file mode 100644 index 44e1aeaa4..000000000 --- a/roles/files/tests/fixtures/template/present.j2 +++ /dev/null @@ -1 +0,0 @@ -Template {{ 'present' }} diff --git a/roles/files/tests/tmp/.gitignore b/roles/files/tests/tmp/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/roles/files/tests/tmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/roles/git/.gitignore b/roles/git/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/git/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/git/.manala/make/Makefile b/roles/git/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/git/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/git/.manala/make/Makefile.docker b/roles/git/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/git/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/git/.manala/make/Makefile.host b/roles/git/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/git/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/git/.manala/make/Makefile.manala b/roles/git/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/git/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/git/.manala/make/Makefile.travis b/roles/git/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/git/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/git/.manala/make/gmsl/__gmsl b/roles/git/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/git/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/git/.manala/make/gmsl/gmsl b/roles/git/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/git/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/git/.travis.yml b/roles/git/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/git/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/git/CHANGELOG.md b/roles/git/CHANGELOG.md deleted file mode 100644 index f583dd6f9..000000000 --- a/roles/git/CHANGELOG.md +++ /dev/null @@ -1,65 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.5] - 2021-02-23 -### Fixed -- Fix templates - -## [2.0.4] - 2021-02-23 -### Fixed -- Fix config filter - -## [2.0.3] - 2021-02-22 -### Added -- Dict based config filters - -# Changed -- Deprecate dict's array config - -## [2.0.2] - 2020-08-26 -### Changed -- Explicit file permissions - -## [2.0.1] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.5] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.4] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.3] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.2] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.1] - 2017-09-26 -### Added -- Allow to clone repositories as specified user -- Fix tests - -## [1.0.0] - 2017-06-21 -### Added -- Handle installation -- Handle config -- Handle repositories diff --git a/roles/git/Makefile b/roles/git/Makefile deleted file mode 100644 index 093f3681e..000000000 --- a/roles/git/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.git -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/git/README.md b/roles/git/README.md index 3f83e3a7d..776ec46c4 100644 --- a/roles/git/README.md +++ b/roles/git/README.md @@ -1,23 +1,11 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Git [![Build Status](https://travis-ci.org/manala/ansible-role-git.svg?branch=master)](https://travis-ci.org/manala/ansible-role-git) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Git This role will deal with the setup and configuration of git by: - Installing GIT package - Define the gitconfig file - Allow setup of the giconfig file -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -29,34 +17,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.git -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.git -``` - -## Role Handlers - -None +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| ------------------------------------- | ----------------- | ------------ | -------------------------------------- | -| `manala_git_install_packages` | ~ | Array | Dependency packages to install | -| `manala_git_install_packages_default` | ['git'] | Array | Default dependency packages to install | -| `manala_git_config_file` | '/etc/gitconfig' | String | Configuration file path | -| `manala_git_config_template` | 'config/empty.j2' | String | Configuration template path | -| `manala_git_config` | ~ | Array/String | Git config options | -| `manala_git_repositories` | [] | Array | List of repositories to checkout | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### GIT configuration @@ -91,16 +56,6 @@ manala_git_config: | filemode = false ``` -Use dict's array parameters (deprecated): -```yaml -manala_git_config: - - user: - - name: Foo Bar - - email: foo.bar@manala.io - - core: - - filemode: false -``` - ### Auto-checkout of required repositories The `manala_git_repositories` key is a "special one", it's designed to allow automatic checkout of specified repositories: @@ -130,13 +85,16 @@ manala_git_repositories: ```yaml - hosts: servers - roles: - - role: manala.git + tasks: + - import_role: + name: manala.roles.git ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/git/filter_plugins/.gitignore b/roles/git/filter_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/git/filter_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/git/filter_plugins/manala_git_config.py b/roles/git/filter_plugins/manala_git_config.py deleted file mode 100644 index e09314585..000000000 --- a/roles/git/filter_plugins/manala_git_config.py +++ /dev/null @@ -1,76 +0,0 @@ -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -from ansible.errors import AnsibleFilterError -from ansible.module_utils.six import iteritems, string_types -from ansible.plugins.filter.core import flatten - -from numbers import Number - - -def config(sections, exclude=[]): - if not isinstance(sections, dict): - raise AnsibleFilterError('manala_git_config expects a dict but was given a %s' % type(sections)) - [sections.pop(key, None) for key in exclude] - result = '' - for section, parameters in sorted(iteritems(sections)): - result += '[%s]%s\n\n' % ( - section, - config_section(parameters) - ) - return result.rsplit('\n', 1)[0] - - -def config_section(parameters, exclude=[]): - if not isinstance(parameters, dict): - raise AnsibleFilterError('manala_git_config_section expects a dict but was given a %s' % type(parameters)) - [parameters.pop(key, None) for key in exclude] - result = '' - for key in sorted(parameters): - parameter = config_parameter(parameters, key) - if parameter: - result += '\n %s' % parameter - return result - - -def config_parameter(parameters, key, required=False, default=None, comment=False): - if not isinstance(parameters, dict): - raise AnsibleFilterError('manala_git_config_parameter parameters expects a dict but was given a %s' % type(parameters)) - if not isinstance(key, string_types): - raise AnsibleFilterError('manala_git_config_parameter key expects a string but was given a %s' % type(key)) - if required and key not in parameters: - raise AnsibleFilterError('manala_git_config_parameter requires a value for key %s' % key) - - value = parameters.get(key, default) - - if value is True: - value = 'true' - elif value is False: - value = 'false' - elif isinstance(value, (string_types, Number)): - pass - else: - AnsibleFilterError('manala_git_config_parameter value of an unknown type %s' % type(value)) - - result = '%s = %s' % (key, value) - - if key not in parameters: - if comment is True: - result = ';' + result.replace('\n', '\n;') - elif isinstance(comment, string_types): - result = comment - - return result - - -class FilterModule(object): - ''' Manala git config jinja2 filters ''' - - def filters(self): - filters = { - 'manala_git_config': config, - 'manala_git_config_section': config_section, - 'manala_git_config_parameter': config_parameter, - } - - return filters diff --git a/roles/git/meta/main.yml b/roles/git/meta/main.yml index 43f041ef9..82355f43d 100644 --- a/roles/git/meta/main.yml +++ b/roles/git/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: git - author: Manala - company: Manala - description: Handle git - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: git + author: Manala + company: Manala + description: Handle git + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - system - developpement diff --git a/roles/git/tasks/config.yml b/roles/git/tasks/config.yml index 5916921ba..47d72840f 100644 --- a/roles/git/tasks/config.yml +++ b/roles/git/tasks/config.yml @@ -8,4 +8,4 @@ group: root mode: "0644" when: manala_git_config_template - or manala_git_config + or manala_git_config diff --git a/roles/git/tasks/install.yml b/roles/git/tasks/install.yml index 1dc56f4cb..86e1d7705 100644 --- a/roles/git/tasks/install.yml +++ b/roles/git/tasks/install.yml @@ -2,7 +2,9 @@ - name: install > Packages apt: - name: "{{ manala_git_install_packages|default(manala_git_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_git_install_packages|default(manala_git_install_packages_default, True) }}" diff --git a/roles/git/tasks/repositories.yml b/roles/git/tasks/repositories.yml index 18bbc2f84..48bcf3c3f 100644 --- a/roles/git/tasks/repositories.yml +++ b/roles/git/tasks/repositories.yml @@ -8,7 +8,7 @@ clone: "{{ item.clone|default(omit) }}" update: "{{ item.update|default(true)|bool }}" version: "{{ item.version|default(omit) }}" - with_items: "{{ manala_git_repositories }}" + loop: "{{ manala_git_repositories }}" when: item.user is undefined - name: repositories > Setup git repositories as specified user @@ -21,5 +21,5 @@ version: "{{ item.version|default(omit) }}" become: true become_user: "{{ item.user }}" - with_items: "{{ manala_git_repositories }}" + loop: "{{ manala_git_repositories }}" when: item.user is defined diff --git a/roles/git/templates/config/_default.j2 b/roles/git/templates/config/_default.j2 index 638fff754..64beec4ad 100644 --- a/roles/git/templates/config/_default.j2 +++ b/roles/git/templates/config/_default.j2 @@ -2,14 +2,7 @@ {%- if config is mapping -%} -{{ config | manala_git_config }} - -{%- elif config is iterable and config is not string -%} - -{#- Deprecated -#} -{%- import '_macros.j2' as macros with context -%} - -{{ macros.config(config) }} +{{ config | manala.roles.git_config }} {%- else -%} diff --git a/roles/git/templates/config/_macros.j2 b/roles/git/templates/config/_macros.j2 deleted file mode 100644 index a87fb2569..000000000 --- a/roles/git/templates/config/_macros.j2 +++ /dev/null @@ -1,66 +0,0 @@ -{#- Deprecated -#} - -{%- macro config(parameters, exclusions = [], indent = 0) -%} - {%- for parameter in parameters -%} - {%- if parameter is string or parameter is number -%} - {{ parameter }}{{ '\n' }} - {%- elif parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key not in exclusions -%} - {{ _config_parameter(parameter_key, parameter_value, indent) }}{{ '\n' }} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} -{%- endmacro -%} - -{%- macro config_row(parameters, key, default, indent = 0, placeholder = false) -%} - {%- set vars = {'values': []} -%} - {%- for parameter in parameters -%} - {%- if parameter is mapping -%} - {%- for parameter_key, parameter_value in parameter.items() -%} - {%- if parameter_key == key -%} - {%- if vars.update({'values': vars['values'] + [parameter_value]}) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} - {%- endif -%} - {%- endfor -%} - {%- if vars['values']|length -%} - {%- for value in vars['values'] -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- else -%} - {%- if placeholder -%} - {{ default }} - {%- else -%} - {%- for value in (default if (default is sequence and default is not string) else [default]) -%} - {{ _config_parameter(key, value, indent) }}{% if not loop.last %}{{ '\n' }}{% endif %} - {%- endfor -%} - {%- endif -%} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter(key, value, indent = 0) -%} - {%- if value is sequence and value is not string -%} - [{{ key }}]{{ '\n' }}{{ config(value, [], indent + 4) }} - {%- else -%} - {{ _config_parameter_key(key)|indent(indent, true) }} = {{ _config_parameter_value(value) }} - {%- endif -%} -{%- endmacro -%} - -{%- macro _config_parameter_key(key) -%} - {{ key }} -{%- endmacro -%} - -{%- macro _config_parameter_value(value) -%} - {%- if value is sameas none -%} - {%- elif value is sameas true -%} - true - {%- elif value is sameas false -%} - false - {%- elif value is string -%} - {{ value }} - {%- elif value is number -%} - {{ value }} - {%- endif -%} -{%- endmacro -%} diff --git a/roles/git/templates/config/default.dev.j2 b/roles/git/templates/config/default.dev.j2 deleted file mode 100644 index f24bd1108..000000000 --- a/roles/git/templates/config/default.dev.j2 +++ /dev/null @@ -1,37 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_git_config|default([], true) -%} - -{% set config_core = [] -%} -{% set config_oh_my_zsh = [] -%} - -{%- for configs in config -%} - {%- for config_name, config_parameters in configs.items() -%} - {%- if config_name == 'core' -%} - {%- if config_core.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'oh-my-zsh' -%} - {%- if config_oh_my_zsh.extend(config_parameters) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} -{%- endfor -%} - -[core] -{# See: http://git.661346.n2.nabble.com/git-status-takes-30-seconds-on-Windows-7-Why-td7580816.html #} -{{ macros.config_row(config_core, 'preloadindex', true, 4) }} -{# See: https://news.ycombinator.com/item?id=11388479 #} -{{ macros.config_row(config_core, 'untrackedCache', true, 4) }} -{{ macros.config(config_core, [ - 'preloadindex', - 'untrackedCache' -], 4) }} - -[oh-my-zsh] -{# See: http://marc-abramowitz.com/archives/2012/04/10/fix-for-oh-my-zsh-git-svn-prompt-slowness/ #} -{{ macros.config_row(config_oh_my_zsh, 'hide-status', 1, 4) }} -{{ macros.config(config_oh_my_zsh, [ - 'hide-status' -], 4) }} - -{{ macros.config(config, ['core', 'oh-my-zsh']) }} diff --git a/roles/git/templates/config/default.prod.j2 b/roles/git/templates/config/default.prod.j2 deleted file mode 100644 index 28936174b..000000000 --- a/roles/git/templates/config/default.prod.j2 +++ /dev/null @@ -1,27 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_git_config|default([], true) -%} - -{% set config_core = [] -%} - -{%- for configs in config -%} - {%- for config_name, config_parameters in configs.items() -%} - {%- if config_name == 'core' -%} - {%- if config_core.extend(config_parameters) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} -{%- endfor -%} - -[core] -{# See: http://git.661346.n2.nabble.com/git-status-takes-30-seconds-on-Windows-7-Why-td7580816.html #} -{{ macros.config_row(config_core, 'preloadindex', true, 4) }} -{# See: https://news.ycombinator.com/item?id=11388479 #} -{{ macros.config_row(config_core, 'untrackedCache', true, 4) }} -{{ macros.config(config_core, [ - 'preloadindex', - 'untrackedCache' -], 4) }} - -{{ macros.config(config, ['core']) }} diff --git a/roles/git/templates/config/default.test.j2 b/roles/git/templates/config/default.test.j2 deleted file mode 100644 index bc0a11447..000000000 --- a/roles/git/templates/config/default.test.j2 +++ /dev/null @@ -1,20 +0,0 @@ -{#- Deprecated -#} - -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_git_config|default([], true) -%} - -{% set config_core = [] -%} -{% set config_oh_my_zsh = [] -%} - -{%- for configs in config -%} - {%- for config_name, config_parameters in configs.items() -%} - {%- if config_name == 'core' -%} - {%- if config_core.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'oh-my-zsh' -%} - {%- if config_oh_my_zsh.extend(config_parameters) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} -{%- endfor -%} - -{{ macros.config(config, ['core', 'oh-my-zsh']) }} diff --git a/roles/git/tests/.gitignore b/roles/git/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/git/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/git/tests/0000_default.goss.yml b/roles/git/tests/0000_default.goss.yml deleted file mode 100644 index 8061a7d7f..000000000 --- a/roles/git/tests/0000_default.goss.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- - -package: - git: - installed: true - -file: - /tmp/ansible-role-git/.git: - exists: true - filetype: directory - owner: root - group: root - mode: "0755" - /tmp/ansible-role-git-user/.git: - exists: true - filetype: directory - owner: manala - mode: "0755" diff --git a/roles/git/tests/0000_default.yml b/roles/git/tests/0000_default.yml deleted file mode 100644 index 8bb287e16..000000000 --- a/roles/git/tests/0000_default.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/backports.yml - - - block: - - import_role: - name: manala.git - vars: - manala_git_repositories: - - repo: https://github.com/manala/ansible-role-git.git - dest: /tmp/ansible-role-git - - repo: https://github.com/manala/ansible-role-git.git - dest: /tmp/ansible-role-git-user - user: manala - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/git/tests/0200_config.goss.yml b/roles/git/tests/0200_config.goss.yml deleted file mode 100644 index 00746d40d..000000000 --- a/roles/git/tests/0200_config.goss.yml +++ /dev/null @@ -1,60 +0,0 @@ ---- - -file: - tmp/config/default/default: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "[foo]" - - " foo = true" - - " bar = false" - - "[bar]" - - " foo = bar" - - " bar = 123" - tmp/config/default/default_deprecated: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "[foo]" - - " foo = true" - - " bar = false" - - "[bar]" - - " foo = bar" - - " bar = 123" - tmp/config/default/default_content: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "[foo]" - - " foo = true" - - " bar = false" - - "[bar]" - - " foo = bar" - - " bar = 123" - tmp/config/default/template: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "Config foo" - tmp/config/default/template_deprecated: - exists: true - filetype: file - owner: root - group: root - mode: "0644" - contains: - - "[core]" - - " preloadindex = false" - - " untrackedCache = true" diff --git a/roles/git/tests/0200_config.yml b/roles/git/tests/0200_config.yml deleted file mode 100644 index 74a6e9818..000000000 --- a/roles/git/tests/0200_config.yml +++ /dev/null @@ -1,76 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/backports.yml - - - block: - - file: - path: tmp/config/default - state: "{{ item }}" - loop: [absent, directory] - # Default - - import_role: - name: manala.git - tasks_from: config - vars: - manala_git_config_file: tmp/config/default/default - manala_git_config: - foo: - foo: true - bar: false - bar: - foo: bar - bar: 123 - # Default - Deprecated - - import_role: - name: manala.git - tasks_from: config - vars: - manala_git_config_file: tmp/config/default/default_deprecated - manala_git_config: - - foo: - - foo: true - - bar: false - - bar: - - foo: bar - - bar: 123 - # Default - Content - - import_role: - name: manala.git - tasks_from: config - vars: - manala_git_config_file: tmp/config/default/default_content - manala_git_config: | - [foo] - foo = true - bar = false - - [bar] - foo = bar - bar = 123 - # Template - - import_role: - name: manala.git - tasks_from: config - vars: - manala_git_config_file: tmp/config/default/template - manala_git_config_template: config/foo.j2 - # Template - Deprecated - - import_role: - name: manala.git - tasks_from: config - vars: - manala_git_config_file: tmp/config/default/template_deprecated - manala_git_config_template: config/default.dev.j2 - manala_git_config: - - core: - - preloadindex: false - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/git/tests/pre_tasks/backports.yml b/roles/git/tests/pre_tasks/backports.yml deleted file mode 100644 index 0d3de0adb..000000000 --- a/roles/git/tests/pre_tasks/backports.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -# Jessie repositories have been archived, meaning that some of them -# (backports, for instance) will remain invalid forever. -- name: Pre tasks > Backports apt repository validity - copy: - dest: /etc/apt/apt.conf.d/archive - content: | - Acquire::Check-Valid-Until "false"; - when: ansible_distribution_release in ['jessie'] - -- name: Pre tasks > Backports apt repository - apt_repository: - repo: deb http://{{ (ansible_distribution_release in ['jessie'])|ternary('archive', 'deb') }}.debian.org/debian {{ ansible_distribution_release }}-backports main diff --git a/roles/git/tests/templates/config/foo.j2 b/roles/git/tests/templates/config/foo.j2 deleted file mode 100644 index 88a54bf6c..000000000 --- a/roles/git/tests/templates/config/foo.j2 +++ /dev/null @@ -1 +0,0 @@ -Config foo diff --git a/roles/git/tests/tmp/.gitignore b/roles/git/tests/tmp/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/roles/git/tests/tmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/roles/gitlab/.gitignore b/roles/gitlab/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/gitlab/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/gitlab/.manala/make/Makefile b/roles/gitlab/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/gitlab/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/gitlab/.manala/make/Makefile.docker b/roles/gitlab/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/gitlab/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/gitlab/.manala/make/Makefile.host b/roles/gitlab/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/gitlab/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/gitlab/.manala/make/Makefile.manala b/roles/gitlab/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/gitlab/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/gitlab/.manala/make/Makefile.travis b/roles/gitlab/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/gitlab/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/gitlab/.manala/make/gmsl/__gmsl b/roles/gitlab/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/gitlab/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/gitlab/.manala/make/gmsl/gmsl b/roles/gitlab/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/gitlab/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/gitlab/.travis.yml b/roles/gitlab/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/gitlab/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/gitlab/CHANGELOG.md b/roles/gitlab/CHANGELOG.md deleted file mode 100644 index 7b5a379ed..000000000 --- a/roles/gitlab/CHANGELOG.md +++ /dev/null @@ -1,51 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.4] - 2021-01-15 -### Added -- Flatten configs array - -### Changed -- Use unified exclusive template lookup - -## [2.0.3] - 2020-09-03 -### fixed -- Fix Explicit file permissions - -## [2.0.2] - 2020-08-28 -### Changed -- Explicit file permissions - -## [2.0.1] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.3] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.2] - 2018-06-05 -### Added -- Handle dependency packages to install - -### Changed -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support - -## [1.0.0] - 2017-05-30 -### Added -- Handle installation -- Handle configs diff --git a/roles/gitlab/Makefile b/roles/gitlab/Makefile deleted file mode 100644 index 8f51f2b8e..000000000 --- a/roles/gitlab/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.gitlab -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/gitlab/README.md b/roles/gitlab/README.md index c1e2ce3a7..057019f6a 100644 --- a/roles/gitlab/README.md +++ b/roles/gitlab/README.md @@ -1,20 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Gitlab [![Build Status](https://travis-ci.org/manala/ansible-role-gitlab.svg?branch=master)](https://travis-ci.org/manala/ansible-role-gitlab) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Gitlab This role will assume the setup of [Gitlab](https://about.gitlab.com/). -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -26,37 +14,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.gitlab -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.gitlab -``` - -## Role Handlers - -| Name | Type | Description | -| -------------------- | ------- | --------------------------------------- | -| `gitlab reconfigure` | Service | Reconfigure and restart gitlab services | -| `gitlab restart` | Service | Restart gitlab services | +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| ---------------------------------------- | ------------- | ------- | -------------------------------------------------- | -| `manala_gitlab_install_packages` | ~ | Array | Dependency packages to install | -| `manala_gitlab_install_packages_default` | ['gitlab-ce'] | Array | Default dependency packages to install | -| `manala_gitlab_configs_exclusive` | false | Boolean | If true, will delete any extra configuration files | -| `manala_gitlab_configs_dir` | '/etc/gitlab' | String | Path to the main configuration directory | -| `manala_gitlab_configs_defaults` | {} | Array | Configuration defaults | -| `manala_gitlab_configs` | [] | Array | Configuration files | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example @@ -85,13 +47,16 @@ manala_gitlab_configs: ```yaml - hosts: servers - roles: - - role: manala.gitlab + tasks: + - import_role: + name: manala.roles.gitlab ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/gitlab/lookup_plugins/.gitignore b/roles/gitlab/lookup_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/gitlab/lookup_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/gitlab/lookup_plugins/manala_templates_exclusive.py b/roles/gitlab/lookup_plugins/manala_templates_exclusive.py deleted file mode 100644 index ff57727f0..000000000 --- a/roles/gitlab/lookup_plugins/manala_templates_exclusive.py +++ /dev/null @@ -1,103 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -from ansible.plugins.lookup import LookupBase -from ansible.errors import AnsibleError -from ansible.module_utils._text import to_text - -import os - - -class LookupModule(LookupBase): - - def _recursive_flatten(self, terms): - if not isinstance(terms, list): - raise AnsibleError('Expect a list but was a %s' % type(terms)) - ret = [] - for term in terms: - if isinstance(term, (list, tuple)): - ret.extend( - self._recursive_flatten(term) - ) - else: - ret.append(term) - return ret - - def run(self, terms, variables=None, **kwargs): - - results = [] - - wantstate = kwargs.pop('wantstate', None) - - if wantstate and wantstate not in ['present', 'absent']: - raise AnsibleError('Expect a wanstate of "present" or "absent" but was "%s"' % to_text(wantstate)) - - templates = self._recursive_flatten(terms[0]) - exclusives = self._flatten(terms[1]) - dir = terms[2] - template = terms[3] - - itemDefault = { - 'state': 'present', - 'template': template - } - - # Mark exclusive templates as absent - for template in exclusives: - item = itemDefault.copy() - item.update({ - 'file': template['path'], - 'state': 'absent' - }) - results.append(item) - - for template in templates: - - items = [] - - # Must be a dict - if not isinstance(template, dict): - raise AnsibleError('Expect a dict but was a %s' % type(template)) - - # Check file key - if 'file' not in template: - # File name based on template - if 'template' in template: - template['file'] = os.path.splitext( - os.path.basename(template['template']) - )[0] - else: - raise AnsibleError('Expect a "file" key') - - item = itemDefault.copy() - item.update(template) - - if item['state'] not in ['present', 'absent', 'ignore']: - raise AnsibleError('Expect a state of "present", "absent" or "ignore" but was "%s"' % to_text(item['state'])) - - if item['state'] == 'ignore': - continue - - item.update({ - 'file': os.path.join(dir, item['file']) - }) - - items.append(item) - - # Merge by file key - for item in items: - itemFound = False - for i, result in enumerate(results): - if result['file'] == item['file']: - results[i] = item - itemFound = True - break - - if not itemFound: - results.append(item) - - # Filter by state - if wantstate: - results = [result for result in results if result.get('state') == wantstate] - - return results diff --git a/roles/gitlab/meta/main.yml b/roles/gitlab/meta/main.yml index f105b8ef8..1f465e713 100644 --- a/roles/gitlab/meta/main.yml +++ b/roles/gitlab/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: gitlab - author: Manala - company: Manala - description: Handle gitlab - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: gitlab + author: Manala + company: Manala + description: Handle gitlab + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - development - git diff --git a/roles/gitlab/tasks/configs.yml b/roles/gitlab/tasks/configs.yml index 944db4c53..3947652dd 100644 --- a/roles/gitlab/tasks/configs.yml +++ b/roles/gitlab/tasks/configs.yml @@ -1,17 +1,9 @@ --- -- name: configs > Directory - file: - path: "{{ manala_gitlab_configs_dir }}" - state: directory - owner: root - group: root - mode: "0755" - when: manala_gitlab_configs|length - - name: configs > Exclusive find: path: "{{ manala_gitlab_configs_dir }}" + file_type: file patterns: "*" changed_when: false register: __manala_gitlab_configs_exclusive_find @@ -25,14 +17,13 @@ group: root mode: "0600" loop: "{{ query( - 'manala_templates_exclusive', - manala_gitlab_configs, - __manala_gitlab_configs_exclusive_find.files|default([]), - manala_gitlab_configs_dir, - manala_gitlab_configs_defaults.template|default('configs/_default.j2', true), - wantstate='present' - ) - }}" + 'manala.roles.templates_exclusive', + manala_gitlab_configs, + __manala_gitlab_configs_exclusive_find.files|default([]), + manala_gitlab_configs_dir, + manala_gitlab_configs_defaults.template|default('configs/_default.j2', true), + wantstate='present' + ) }}" notify: - gitlab reconfigure @@ -41,13 +32,12 @@ path: "{{ item.file }}" state: absent loop: "{{ query( - 'manala_templates_exclusive', - manala_gitlab_configs, - __manala_gitlab_configs_exclusive_find.files|default([]), - manala_gitlab_configs_dir, - manala_gitlab_configs_defaults.template|default('configs/_default.j2', true), - wantstate='absent' - ) - }}" + 'manala.roles.templates_exclusive', + manala_gitlab_configs, + __manala_gitlab_configs_exclusive_find.files|default([]), + manala_gitlab_configs_dir, + manala_gitlab_configs_defaults.template|default('configs/_default.j2', true), + wantstate='absent' + ) }}" notify: - gitlab reconfigure diff --git a/roles/gitlab/tasks/install.yml b/roles/gitlab/tasks/install.yml index ac121a03a..3ac9165fe 100644 --- a/roles/gitlab/tasks/install.yml +++ b/roles/gitlab/tasks/install.yml @@ -2,7 +2,9 @@ - name: install > Packages apt: - name: "{{ manala_gitlab_install_packages|default(manala_gitlab_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_gitlab_install_packages|default(manala_gitlab_install_packages_default, True) }}" diff --git a/roles/gitlab/tests/.gitignore b/roles/gitlab/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/gitlab/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/gitlab/tests/0000_default.yml b/roles/gitlab/tests/0000_default.yml deleted file mode 100644 index b513f411a..000000000 --- a/roles/gitlab/tests/0000_default.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/gitlab.yml - - - block: - - import_role: - name: manala.gitlab - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/gitlab/tests/0200_configs.goss.yml b/roles/gitlab/tests/0200_configs.goss.yml deleted file mode 100644 index 3eba0e424..000000000 --- a/roles/gitlab/tests/0200_configs.goss.yml +++ /dev/null @@ -1,104 +0,0 @@ ---- - -# Default -{{ if has "default" .Vars.tags }} -file: - tmp/configs/default: - exists: true - filetype: directory - owner: root - group: root - mode: "0755" - tmp/configs/default/default_content.rb: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - contains: - - "## GitLab configuration settings" - - "external_url 'http://gitlab.example.com'" - tmp/configs/default/template.rb: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - contains: - - "Configs foo" -{{ end }} - -# State -{{ if has "state" .Vars.tags }} -file: - tmp/configs/state/foo.rb: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - size: 1 - tmp/configs/state/bar.rb: - exists: false - tmp/configs/state/baz.rb: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - size: 1 - tmp/configs/state/qux.rb: - exists: true - filetype: file - tmp/configs/state/quux.rb: - exists: false -{{ end }} - -# Defaults -{{ if has "defaults" .Vars.tags }} -file: - tmp/configs/defaults/foo.rb: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - contains: - - "Configs foo" - tmp/configs/defaults/bar.rb: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - contains: - - "Configs bar" - tmp/configs/defaults/baz.rb: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - contains: - - "Configs bar" -{{ end }} - -# Exclusive -{{ if has "exclusive" .Vars.tags }} -file: - tmp/configs/exclusive/foo.rb: - exists: false - tmp/configs/exclusive/bar.rb: - exists: true - filetype: file - owner: root - group: root - mode: "0600" - size: 1 - tmp/configs/exclusive/baz.rb: - exists: false - tmp/configs/exclusive/qux.rb: - exists: false - tmp/configs/exclusive/quux.rb: - exists: false -{{ end }} diff --git a/roles/gitlab/tests/0200_configs.yml b/roles/gitlab/tests/0200_configs.yml deleted file mode 100644 index ec823de42..000000000 --- a/roles/gitlab/tests/0200_configs.yml +++ /dev/null @@ -1,119 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - tags: [always] - block: - - import_tasks: pre_tasks/gitlab.yml - - # Default - - tags: [default] - block: - - file: - path: tmp/configs/default - state: absent - - import_role: - # Play role fully on first run, so that handlers don't breaks - name: manala.gitlab - vars: - manala_gitlab_configs_dir: tmp/configs/default - manala_gitlab_configs: - # Default - Content - - file: default_content.rb - config: | - ## GitLab configuration settings - external_url 'http://gitlab.example.com' - # Flatten - - - # Template - - file: template.rb - template: configs/foo.rb.j2 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [default]}" validate - - # State - - tags: [state] - block: - - file: - path: tmp/configs/state - state: "{{ item }}" - loop: [absent, directory] - - file: - path: tmp/configs/state/{{ item }}.rb - state: touch - loop: [bar, qux] - - import_role: - name: manala.gitlab - tasks_from: configs - vars: - manala_gitlab_configs_dir: tmp/configs/state - manala_gitlab_configs: - - file: foo.rb - - file: bar.rb - state: absent - - file: baz.rb - state: present - - file: qux.rb - state: ignore - - file: quux.rb - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [state]}" validate - - # Defaults - - tags: [defaults] - block: - - file: - path: tmp/configs/defaults - state: absent - - import_role: - name: manala.gitlab - tasks_from: configs - vars: - manala_gitlab_configs_dir: tmp/configs/defaults - manala_gitlab_configs_defaults: - template: configs/foo.rb.j2 - manala_gitlab_configs: - - file: foo.rb - - template: configs/bar.rb.j2 - - file: baz.rb - template: configs/bar.rb.j2 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [defaults]}" validate - - # Exclusive - - tags: [exclusive] - block: - - file: - path: tmp/configs/exclusive - state: "{{ item }}" - loop: [absent, directory] - - file: - path: tmp/configs/exclusive/{{ item }}.rb - state: touch - loop: [foo, bar, baz, qux] - - import_role: - name: manala.gitlab - tasks_from: configs - vars: - manala_gitlab_configs_dir: tmp/configs/exclusive - manala_gitlab_configs_exclusive: true - manala_gitlab_configs: - - file: bar.rb - - file: qux.rb - state: ignore - - file: quux.rb - state: ignore - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [exclusive]}" validate diff --git a/roles/gitlab/tests/pre_tasks/apt_keys/gitlab.pgp b/roles/gitlab/tests/pre_tasks/apt_keys/gitlab.pgp deleted file mode 100644 index d7b27ff12..000000000 --- a/roles/gitlab/tests/pre_tasks/apt_keys/gitlab.pgp +++ /dev/null @@ -1,52 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- - -mQINBF5dI2sBEACyGx5isuXqEV2zJGIx8rlJFCGw6A9g5Zk/9Hj50UpXNuOXlvQl -7vq91m2CAh88Jad7OiMHIJJhX3ZJEOf/pUx/16QKumsaEyBk9CegxUG9jAQXsjL3 -WLyP0/l27UzNrOAFB+IUGjsoP+32gsSPiF5P485mirIJNojIAFzDQl3Uo4FbvqYU -9AIRk5kV4nEYz1aKXAovIUsyqrztMtwlAG2xqdwVpGD2A4/w8I143qPGjjhEQmf4 -/EeS4CP9ztyLAx+01t2Acwa7Bygsb5KQPuT25UlevuxdDy/Rd5Zn/Lzwr2GQqjUs -6GbM0t1HYjh57e4V+p0qMf6jxXfrDCbehgzFvGS0cx/d7hWHm5sXZIt3gxpjBQU2 -8MQWtrR8Y3nTBkCHwOKsXdsdD+YHxTq/yuvxl1Bcyshp29cGWv1es3wn2Z6i9tWe -asGfVewJZiXFSEqSBGguEmLyCAZcWgXvHOV2kc66wG4d4TGIxmoo9GBqEtBftCVH -MGDHt7zeg2hg6EIsx8/nj1duO5nBnbnik5iG8Xv46e/aw2p4DfTdfxHpjvyJudyN -+UI5eSuuuXhyTZWedd5K1Q3+0CmACJ39t/NA6g7cZaw3boFKw3fTWIgOVTvC3y5v -d7wsuyGUk9xNhHLcu6HjB4VPGzcTwQWMFf6+I4qGAUykU5mjTJchQeqmQwARAQAB -tEJHaXRMYWIgQi5WLiAocGFja2FnZSByZXBvc2l0b3J5IHNpZ25pbmcga2V5KSA8 -cGFja2FnZXNAZ2l0bGFiLmNvbT6JAlQEEwEKAD4WIQT2QD9lRKOIY9qgtuA/AWGK -UTEvPwUCXl0jawIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRA/ -AWGKUTEvP3/+EACEpR4JwFz7fAZxKoTzq1xkv7JiVC1jDnfZ6U6tumMDSIBLqlZX -Jv/lixuXC/GCnyiduqqpO14RCkHrCECzNeu7+lt+eiBUpOKvDgkNid6FLMoulu1w -hDhQWss6+40dIWwa5i8maIFg6WOwIiI24PW9T+ywrf2Gfv9mB1YP3ob+8Cx1EVb/ -sf5mu1SGHvq2PqNvPeyY3W5vU7rB0Ax5Kcn3e0Z+tUSC8fV7TCg9hm9o2Ou928K4 -hmvdFfR0t47cXt1wmZ/pjrWcezVqeIrMJyWtje4hgcO3TSXsfvedEdYn8Q/BgVRw -9KL4DkR1HSemSsPB4YyOwLscjV6p5OCPm0PhPPXUGIdImcQH7jYuEXNi5nnN5dX4 -197ooTB2UCk8r0QtnhcQUE2ph46mylcksbR0nKhGh5bYW3jfd0X+MP36reo+EFQ7 -Sw35f7P7QvZqnEE8rd5fX3GImKm38xJi+9bGb4IH8WuslUZUMapgQqqBfw1k5+mP -BBqKWSdEsP1i7LBv9jVOaauMYQPLZcodx5prgjrB89V1hCKu+ZQl/hzoCwmeSruD -LUqX/RFeleZO2VeKXh1a/VQ69ThqZ7gyXcrvHopPPGTr9IESoV9/qcZWplEccP9b -FuY9t6HuSpcL7SlbsRVQ0NBQrsQeZR2J0YgvRc3JWgZAfcE5MK2jcoWKCLkCDQRe -XSNrARAApHc0R4tfPntr5bhTuXU/iVLyxlAlzdEv1XsdDC8YBYehT72Jpvpphtq7 -sKVsuC59l8szojgO/gW//yKSuc3Gm5h58+HpIthjviGcvZXf/JcN7Pps0UGkLeQN -2+IRZgbA6CAAPh2njE60v5iXgS91bxlSJi8GVHq1h28kbKQeqUYthu9yA2+8J4Fz -ivYV2VImKLSxbQlc86tl6rMKKIIOph+N4WujJgd5HZ80n2qp1608X3+9CXvtBasX -VCI2ZqCuWjffVCOQzsqRbJ6LQyMbgti/23F4Yqjqp+8eyiDNL6MyWJCBbtkW3Imi -FHfR0sQIM6I7fk0hvt9ljx9SG6az/s3qWK5ceQ7XbJgCAVS4yVixfgIjWvNE5ggE -QNOmeF9r76t0+0xsdMYJR6lxdaQI8AAYaoMXTkCXX2DrASOjjEP65Oq/d42xpSf9 -tG6XIq+xtRQyFWSMc+HfTlEHbfGReAEBlJBZhNoAwpuDckOC08vw7v2ybS5PYjJ4 -5Kzdwej0ga03Wg9hrAFd/lVa5eO4pzMLuexLplhpIbJjYwCUGS4cc/LQ2jq4fue5 -oxDpWPN+JrBH8oyqy91b10e70ohHppN8dQoCa79ySgMxDim92oHCkGnaVyULYDqJ -zy0zqbi3tJu639c4pbcggxtAAr0I3ot8HPhKiNJRA6u8HTm//xEAEQEAAYkCPAQY -AQoAJhYhBPZAP2VEo4hj2qC24D8BYYpRMS8/BQJeXSNrAhsMBQkDwmcAAAoJED8B -YYpRMS8/vzQP/iO0poRR9ZYjonP5GGIARRnF+xpWCRTZVSHLcAfS0ujZ7ekXoeeS -JNMJ/7T4Yk1EJ9MTFZ83Jj4UybKO3Rw+/iPmcPpqUQGaEReYLlx7SyxmsOBXf+Q9 -PtyUmGO47tL+eAPInYyxsWGib/EeOw4KQrfByAIPWu0aeNeXadzxBLIkqD863H5q -nTDrXOw6SLprlGt2zlc+XQKDv3DZez6wTcp205xdaNs55Bfk9pmKUS/ey3ZP7GvC -CDEGxuWulVSKL2DYtq0sEZD7pQYSy8gBTqXLQAyfmPDcxe9Lczhk3UYrUUomN1/w -+VE09q75yNqkaHdckVt+aYAHMgQ0ilmwTg6+OlEK+ZQkUT94viB6YW7B0M4uzols -9FSDxXea/uKn75jTSkA3GAXf7O5hqbkDDctJbtO2pPdLDxbXN95iZ9xpgRE3exGl -ucjgV5XGpLO4XXf0GTzug/TJAtNljJ/44+6meO0WwOwLMMhAJVxcp1fpbtgRmrcJ -8bAsCkV5EO8SeQZDu2C8I9tMGlJ1VLTAfv6Lv2Z89B1AOOweGz4I48i9lux+HdXd -HewnA37zx0XNjNQmqiG85UWUusnDxF0Je2jEhGIpHK/KdyI1BfNzX3d5HVoM1VE3 -THtRZHnetoMek8L5x/ciYQNIt40rQ6MHtPEo1ZC4346DP6eJmeX1DGGI -=91uZ ------END PGP PUBLIC KEY BLOCK----- diff --git a/roles/gitlab/tests/pre_tasks/gitlab.yml b/roles/gitlab/tests/pre_tasks/gitlab.yml deleted file mode 100644 index f0d75ba0c..000000000 --- a/roles/gitlab/tests/pre_tasks/gitlab.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Pre tasks > Gitlab apt key - apt_key: - file: pre_tasks/apt_keys/gitlab.pgp - id: 51312F3F - -- name: Pre tasks > Gitlab apt repository - apt_repository: - repo: deb https://packages.gitlab.com/gitlab/gitlab-ce/debian/ {{ ansible_distribution_release }} main diff --git a/roles/gitlab/tests/templates/configs/bar.rb.j2 b/roles/gitlab/tests/templates/configs/bar.rb.j2 deleted file mode 100644 index 53e654354..000000000 --- a/roles/gitlab/tests/templates/configs/bar.rb.j2 +++ /dev/null @@ -1 +0,0 @@ -Configs bar diff --git a/roles/gitlab/tests/templates/configs/foo.rb.j2 b/roles/gitlab/tests/templates/configs/foo.rb.j2 deleted file mode 100644 index cdc34797b..000000000 --- a/roles/gitlab/tests/templates/configs/foo.rb.j2 +++ /dev/null @@ -1 +0,0 @@ -Configs foo diff --git a/roles/gitlab/tests/tmp/.gitignore b/roles/gitlab/tests/tmp/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/roles/gitlab/tests/tmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/roles/glusterfs/.gitignore b/roles/glusterfs/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/glusterfs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/glusterfs/.manala/make/Makefile b/roles/glusterfs/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/glusterfs/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/glusterfs/.manala/make/Makefile.docker b/roles/glusterfs/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/glusterfs/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/glusterfs/.manala/make/Makefile.host b/roles/glusterfs/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/glusterfs/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/glusterfs/.manala/make/Makefile.manala b/roles/glusterfs/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/glusterfs/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/glusterfs/.manala/make/Makefile.travis b/roles/glusterfs/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/glusterfs/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/glusterfs/.manala/make/gmsl/__gmsl b/roles/glusterfs/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/glusterfs/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/glusterfs/.manala/make/gmsl/gmsl b/roles/glusterfs/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/glusterfs/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/glusterfs/.travis.yml b/roles/glusterfs/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/glusterfs/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/glusterfs/CHANGELOG.md b/roles/glusterfs/CHANGELOG.md deleted file mode 100644 index 6401d1e3c..000000000 --- a/roles/glusterfs/CHANGELOG.md +++ /dev/null @@ -1,28 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [1.0.3] - 2021-01-11 -### Added -- `ignore` volumes state - -### Changed -- Flatten volumes array - -## [1.0.2] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [1.0.1] - 2019-10-24 -### Added -- Debian buster support - -## [1.0.0] - 2019-05-21 -### Added -- Install Glusterfs-server -- Handling Volumes - diff --git a/roles/glusterfs/Makefile b/roles/glusterfs/Makefile deleted file mode 100644 index 09e70edca..000000000 --- a/roles/glusterfs/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.glusterfs -ROLE_DISTRIBUTIONS = debian.stretch debian.buster diff --git a/roles/glusterfs/README.md b/roles/glusterfs/README.md index a8d91dd2d..918f006d9 100644 --- a/roles/glusterfs/README.md +++ b/roles/glusterfs/README.md @@ -1,24 +1,12 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: GlusterFS [![Build Status](https://travis-ci.org/manala/ansible-role-glusterfs.svg?branch=master)](https://travis-ci.org/manala/ansible-role-glusterfs) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: GlusterFS This role will deal with the configuration of [GlusterFS](https://www.gluster.org/). -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements -This role is made to work with the __glusterfs__ official packages, available on the [__glusterfs__ repository](https://download.gluster.org/pub/gluster/glusterfs). Please use the [**manala.apt**](https://galaxy.ansible.com/manala/apt/) role to handle it properly. +This role is made to work with the __glusterfs__ official packages, available on the [__glusterfs__ repository](https://download.gluster.org/pub/gluster/glusterfs). Please use the [**manala.roles.apt**](../apt/) role to handle it properly. ```yaml manala_apt_preferences: @@ -31,28 +19,11 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.glusterfs -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.glusterfs -``` +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| ----------------------------------------- | -------------------------- | ------- | -------------------------------------- | -| `manala_glusterfs_install_packages` | ~ | Array | Dependency packages to install | -| `manala_glusterfs_install_packages_default` | ['glusterfs-server'] | Array | Default dependency packages to install | -| `manala_glusterfs_volumes` | [] | Array | Volumes settings | - +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example @@ -80,9 +51,11 @@ manala_glusterfs_volumes: - "Options" are expecting strings only. Quotes are required. - To add bricks, use the same syntax on existent volume. -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/glusterfs/meta/main.yml b/roles/glusterfs/meta/main.yml index 8a2ddc7ea..4cab522a8 100644 --- a/roles/glusterfs/meta/main.yml +++ b/roles/glusterfs/meta/main.yml @@ -4,18 +4,19 @@ dependencies: [] galaxy_info: - role_name: glusterfs - author: Manala - company: Manala - description: Handle glusterfs - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: glusterfs + author: Manala + company: Manala + description: Handle glusterfs + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - stretch - buster + - bullseye galaxy_tags: - system - glusterfs diff --git a/roles/glusterfs/tasks/install.yml b/roles/glusterfs/tasks/install.yml index b30ad2212..59de51fc4 100644 --- a/roles/glusterfs/tasks/install.yml +++ b/roles/glusterfs/tasks/install.yml @@ -2,7 +2,9 @@ - name: install > Packages apt: - name: "{{ manala_glusterfs_install_packages|default(manala_glusterfs_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false update_cache: true cache_valid_time: 3600 + loop: + - "{{ manala_glusterfs_install_packages|default(manala_glusterfs_install_packages_default, True) }}" diff --git a/roles/glusterfs/tasks/services.yml b/roles/glusterfs/tasks/services.yml index 9eaf3c0ee..556f4a9fa 100644 --- a/roles/glusterfs/tasks/services.yml +++ b/roles/glusterfs/tasks/services.yml @@ -5,5 +5,5 @@ name: "{{ item }}" state: started enabled: true - with_items: + loop: - glusterd diff --git a/roles/glusterfs/tasks/volumes.yml b/roles/glusterfs/tasks/volumes.yml index 42708c9d0..95f8d509a 100644 --- a/roles/glusterfs/tasks/volumes.yml +++ b/roles/glusterfs/tasks/volumes.yml @@ -11,7 +11,7 @@ options: "{{ item.options|default(omit) }}" host: "{{ item.host|default(omit) }}" loop: "{{ - manala_glusterfs_volumes | flatten | selectattr('state', 'undefined') | list - + - manala_glusterfs_volumes | flatten | selectattr('state', 'defined') | rejectattr('state', 'equalto', 'ignore') | list + manala_glusterfs_volumes + | flatten + | manala.roles.staten(want='present') }}" diff --git a/roles/glusterfs/tests/0000_default.6.1.goss.yml b/roles/glusterfs/tests/0000_default.6.1.goss.yml deleted file mode 100644 index fafbd6793..000000000 --- a/roles/glusterfs/tests/0000_default.6.1.goss.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -package: - glusterfs-server: - installed: true - -service: - glusterd: - running: true diff --git a/roles/glusterfs/tests/0000_default.6.1.yml b/roles/glusterfs/tests/0000_default.6.1.yml deleted file mode 100644 index 77e37f09d..000000000 --- a/roles/glusterfs/tests/0000_default.6.1.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/service.yml - - import_tasks: pre_tasks/glusterfs_6.1.yml - - - block: - - import_role: - name: manala.glusterfs - vars: - manala_redis_sentinel: true - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/glusterfs/tests/0200_volumes.6.1.goss.yml b/roles/glusterfs/tests/0200_volumes.6.1.goss.yml deleted file mode 100644 index fa7c085fb..000000000 --- a/roles/glusterfs/tests/0200_volumes.6.1.goss.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- - -command: - gluster volume info volume_ignore: - exit-status: 0 - stderr: - - "Volume volume_ignore does not exist" - gluster volume info volume_absent: - exit-status: 0 - stderr: - - "Volume volume_absent does not exist" - gluster volume info volume_present: - exit-status: 0 - stderr: - - "Volume volume_present does not exist" - gluster volume info volume_test: - exit-status: 0 - stderr: - - "Volume volume_test does not exist" - -command: - gluster volume info: - exit-status: 0 - stdout: - # Present - - "Volume Name: volume_present" - - "Status: Started" - - "Bricks:" - - "Brick1: manala.glusterfs.debian.{{ .Env.DISTRIBUTION_RELEASE }}.test:/home/present" - # Test - - "Volume Name: volume_test" - - "Status: Started" - - "Bricks:" - - "Brick1: manala.glusterfs.debian.{{ .Env.DISTRIBUTION_RELEASE }}.test:/home/test_1" - - "Brick2: manala.glusterfs.debian.{{ .Env.DISTRIBUTION_RELEASE }}.test:/home/test_2" - - "Brick3: manala.glusterfs.debian.{{ .Env.DISTRIBUTION_RELEASE }}.test:/home/test_3" - - "storage.owner-uid: 1337" - - "storage.owner-gid: 1337" - - "nfs.disable: off" diff --git a/roles/glusterfs/tests/0200_volumes.6.1.yml b/roles/glusterfs/tests/0200_volumes.6.1.yml deleted file mode 100644 index 4ed8a6b22..000000000 --- a/roles/glusterfs/tests/0200_volumes.6.1.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_tasks: pre_tasks/service.yml - - import_tasks: pre_tasks/glusterfs_6.1.yml - - - block: - - file: - path: "{{ item }}" - state: directory - loop: [/home/absent, /home/present, /home/test_1] - - import_role: - # Play role fully on first run, so that handlers don't breaks - name: manala.glusterfs - vars: - manala_glusterfs_volumes: - - name: volume_ignore - state: ignore - - name: volume_absent - bricks: /home/absent - cluster: - - manala.glusterfs.debian.{{ ansible_distribution_release }}.test - force: true - - name: volume_present - bricks: /home/present - cluster: - - manala.glusterfs.debian.{{ ansible_distribution_release }}.test - force: true - # Flatten - - - - name: volume_test - bricks: /home/test_1 - cluster: - - manala.glusterfs.debian.{{ ansible_distribution_release }}.test - options: - storage.owner-gid: "1337" - storage.owner-uid: "1337" - nfs.disable: "off" - force: true - - file: - path: "{{ item }}" - state: directory - loop: [/home/test_2, /home/test_3] - - import_role: - # Play role fully on first run, so that handlers don't breaks - name: manala.glusterfs - tasks_from: volumes - vars: - manala_glusterfs_volumes: - - name: volume_absent - state: absent - - name: volume_test - bricks: /home/test_2,/home/test_3 - cluster: - - manala.glusterfs.debian.{{ ansible_distribution_release }}.test - force: true - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/glusterfs/tests/pre_tasks/apt_keys/glusterfs_6.pgp b/roles/glusterfs/tests/pre_tasks/apt_keys/glusterfs_6.pgp deleted file mode 100644 index d849a1a8b..000000000 --- a/roles/glusterfs/tests/pre_tasks/apt_keys/glusterfs_6.pgp +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- - -mQENBFuapV0BCACv1RMw4VqN2yx/tQfi9Ah80XegXzew7ztt4UNkaYsr/ptywQUf -d1OxfoEvSBcWqM64u5aTcN5m4kF+RCsjMEC6RCLia27GE6o7IJYyXpl7hBs+cfp0 -uT/B/n9MNegqpDDF3pd2NyXSusAepJJi9zXyiUMOtPk4Kyxk7zAuexWfPVzPyNpO -UaKWpsqpCCm/N+fOEToSy5XlIX4WQQqHKv77G0RYqwEsJMDf5cKItGZOX7Tku2rg -3qcu8l4KrGYQ+HyAtzhPmVvMbjJ4fYDrrk5ttk0DDS7WpK0VtBmbq0BQaMHx/+C9 -FDJCn45lH8TorIeyYOFbVasQFUKq421gw4NtABEBAAG0N0dsdXN0ZXIgUGFja2Fn -ZXIgPGdsdXN0ZXJwYWNrYWdlckBkb3dubG9hZC5nbHVzdGVyLm9yZz6JATgEEwEC -ACIFAluapV0CGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEENgfw3C+COM -P9IH/3AUXkvQx+ta2IfdFfMUwmeh5/+Zz6xXag0mHcbCXelkhT6GEZq+kjUdqsNC -Bi0RzjBySZnpIVfK1Z+bvM/JZu6e75XNGMpNnYP1rDgyzz1TZZVJ2yGc77yqCNun -FQHoDJoXxUmUpHcnbkJcuqucEbfQIZubtqJKBGOfMVjz88YFH9c+DZ8RhwBsxSYm -ASxPjM3wloC6YT5cGUN6+IMQRquzMwnBzHe/XXX7Xm1dWHRDLR2ktSM7Slh7qyin -Y3lOEpJnX/uF6i3RJbifxcOr0B+94iB6Ph1fngPxKmlzzRDFRPRr/SmVEtvx5GO1 -kBrIF2T7xHzQJ50aGukh2TSuaaq5AQ0EW5qlXQEIAMG85NuO18G1gnobBt9dQsxq -bE9nXI7dKOAmCUHQxi0XrDJU5qQzmSJ88u1X2ICzVcTG7bKGNmslv8csrxwT9x+Z -Pa5KMtAlf8TIWCpqWqeNwW7+3PElwAhTQbxPoNmcS18q2LworTM25hOiOpOoF7ee -QuuTBYwtbt8AfqNEjODrvo5wWlmOo3Wf22RwCbw0WzvZsBoWvB1xmJiugj8+oy20 -hDunwEUQLaKW1xWTVoWlgiAtNi1rRnRe7NtYGEohe8UQwFPmcK/KhYVsgQNeIhuX -sh5+JAdEphbEnP0jr4zyECRwyHq8TUAiowcE44pcjOklCXL1U9MBbBLrs9BUSccA -EQEAAYkBHwQYAQIACQUCW5qlXQIbDAAKCRBDYH8NwvgjjIV8B/wP1HRz6wY4TZTi -4DuivybF3O9xGzSGF24RnTni3O4J9fbdJYaBjCWyz2wcZWYGbZl1k8iI7Kl7nCy9 -fQ0EPq6Cr1NKqAFGJK8UqALhoyRfDYFoh/YRE1CWPoaIRt5NLByxeFIaeIatp0mq -ST3OVzdblL/4XakBlX3TeIY8zAEx49S93LplZJO7r0YGK8NXZK6r7PRyxZuquNMa -OaNX43XHfPP8mVA3T+pLBsB9ueRW06yIARGOewoN0D1JYv7yVDlN451iKp8oyB+B -i7qv86C1wEg7J0S9WaJcAECPencos8YDwcHJomBKgsgCIT3vtJfrVdyu/55Hvpy8 -Bu5o9YhQ -=EkmO ------END PGP PUBLIC KEY BLOCK----- diff --git a/roles/glusterfs/tests/pre_tasks/glusterfs_6.1.yml b/roles/glusterfs/tests/pre_tasks/glusterfs_6.1.yml deleted file mode 100644 index 3bf5ad03a..000000000 --- a/roles/glusterfs/tests/pre_tasks/glusterfs_6.1.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Pre tasks > Glusterfs apt key - apt_key: - file: pre_tasks/apt_keys/glusterfs_6.pgp - id: C2F8238C - -- name: Pre tasks > Glusterfs apt repository - apt_repository: - repo: deb https://download.gluster.org/pub/gluster/glusterfs/6/6.1/Debian/{{ ansible_distribution_release }}/{{ {'x86_64':'amd64','armv6l':'arm64'}[ansible_architecture] }}/apt {{ ansible_distribution_release }} main diff --git a/roles/glusterfs/tests/pre_tasks/init.d/glusterd b/roles/glusterfs/tests/pre_tasks/init.d/glusterd deleted file mode 100644 index de252b8a3..000000000 --- a/roles/glusterfs/tests/pre_tasks/init.d/glusterd +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh -### BEGIN INIT INFO -# Provides: glusterd -# Required-Start: $local_fs $network -# Required-Stop: $local_fs $network -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Gluster File System service for volume management -# Description: Gluster File System service for volume management -### END INIT INFO - -# Author: Chris AtLee -# Patched by: Matthias Albert < matthias@linux4experts.de> - -PATH=/sbin:/usr/sbin:/bin:/usr/bin -NAME=glusterd -SCRIPTNAME=/etc/init.d/$NAME -DAEMON=/usr/sbin/$NAME -PIDFILE=/var/run/$NAME.pid -GLUSTERD_OPTS="" -PID=`test -f $PIDFILE && cat $PIDFILE` - - -# Gracefully exit if the package has been removed. -test -x $DAEMON || exit 0 - -# Load the VERBOSE setting and other rcS variables -. /lib/init/vars.sh - -# Define LSB log_* functions. -. /lib/lsb/init-functions - - -do_start() -{ - pidofproc -p $PIDFILE $DAEMON >/dev/null - status=$? - if [ $status -eq 0 ]; then - log_success_msg "glusterd service is already running with pid $PID" - else - log_daemon_msg "Starting glusterd service" "glusterd" - start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -p $PIDFILE $GLUSTERD_OPTS - log_end_msg $? - start_daemon -p $PIDFILE $DAEMON -f $CONFIGFILE - return $? - fi -} - -do_stop() -{ - log_daemon_msg "Stopping glusterd service" "glusterd" - start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE - log_end_msg $? - rm -f $PIDFILE - killproc -p $PIDFILE $DAEMON - return $? -} - -do_status() -{ - pidofproc -p $PIDFILE $DAEMON >/dev/null - status=$? - if [ $status -eq 0 ]; then - log_success_msg "glusterd service is running with pid $PID" - else - log_failure_msg "glusterd service is not running." - fi - exit $status -} - -case "$1" in - start) - do_start - ;; - stop) - do_stop - ;; - status) - do_status; - ;; - restart|force-reload) - do_stop - sleep 2 - do_start - ;; - *) - echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 - exit 3 - ;; -esac - diff --git a/roles/glusterfs/tests/pre_tasks/service.yml b/roles/glusterfs/tests/pre_tasks/service.yml deleted file mode 100644 index 07f2d7e9d..000000000 --- a/roles/glusterfs/tests/pre_tasks/service.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -- name: Pre tasks > Install sysv init script - copy: - src: pre_tasks/init.d/glusterd - dest: /etc/init.d/glusterd - mode: 0755 diff --git a/roles/gomplate/.gitignore b/roles/gomplate/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/gomplate/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/gomplate/.manala/make/Makefile b/roles/gomplate/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/gomplate/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/gomplate/.manala/make/Makefile.docker b/roles/gomplate/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/gomplate/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/gomplate/.manala/make/Makefile.host b/roles/gomplate/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/gomplate/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/gomplate/.manala/make/Makefile.manala b/roles/gomplate/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/gomplate/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/gomplate/.manala/make/Makefile.travis b/roles/gomplate/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/gomplate/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/gomplate/.manala/make/gmsl/__gmsl b/roles/gomplate/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/gomplate/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/gomplate/.manala/make/gmsl/gmsl b/roles/gomplate/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/gomplate/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/gomplate/Makefile b/roles/gomplate/Makefile deleted file mode 100644 index af136ae5d..000000000 --- a/roles/gomplate/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = gomplate -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/gomplate/README.md b/roles/gomplate/README.md index 7123b1670..35ddfa24f 100644 --- a/roles/gomplate/README.md +++ b/roles/gomplate/README.md @@ -1,18 +1,8 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - # Ansible Role: Gomplate This role will deal with the installation of [Gomplate](https://github.com/hairyhenderson/gomplate/releases/) -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements @@ -24,48 +14,26 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy collection install manala.roles -``` - -Using ansible galaxy requirements file: - -```yaml -collections: - - manala.roles -``` - -## Role Handlers - -None. +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -### Definition - -| Name | Default | Type | Description | -| ------------------------- | ------------------------ | ------ | -------------------------------------- | -| `manala_gomplate_version` | ~ | String | Version to install, latest by default | -| `manala_gomplate_bin` | '/usr/local/bin/gomplate'| String | Binary path | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ## Example playbook ```yaml - hosts: all - collections: - - manala.roles tasks: - import_role: - name: gomplate + name: manala.roles.gomplate ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/gomplate/filter_plugins/.gitignore b/roles/gomplate/filter_plugins/.gitignore deleted file mode 100644 index 0d20b6487..000000000 --- a/roles/gomplate/filter_plugins/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pyc diff --git a/roles/gomplate/filter_plugins/manala_gomplate.py b/roles/gomplate/filter_plugins/manala_gomplate.py deleted file mode 100644 index 7dba71a50..000000000 --- a/roles/gomplate/filter_plugins/manala_gomplate.py +++ /dev/null @@ -1,25 +0,0 @@ -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -from ansible.errors import AnsibleFilterError - -ARCHITECTURE_MAP = { - 'x86_64': 'amd64', - 'aarch64': 'arm64', -} - -def architecture(architecture): - if architecture not in ARCHITECTURE_MAP: - raise AnsibleFilterError('unsupported "%s" architecture' % architecture) - return ARCHITECTURE_MAP[architecture] - - -class FilterModule(object): - ''' Manala gomplate jinja2 filters ''' - - def filters(self): - filters = { - 'manala_gomplate_architecture': architecture, - } - - return filters diff --git a/roles/gomplate/meta/main.yml b/roles/gomplate/meta/main.yml index c634d89b5..9b4725f88 100644 --- a/roles/gomplate/meta/main.yml +++ b/roles/gomplate/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: gomplate - author: Manala - company: Manala - description: Handle gomplate - license: MIT - min_ansible_version: 2.4.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: gomplate + author: Manala + company: Manala + description: Handle gomplate + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - go - template diff --git a/roles/gomplate/tasks/install.yml b/roles/gomplate/tasks/install.yml index 30911925b..f685f2c3f 100644 --- a/roles/gomplate/tasks/install.yml +++ b/roles/gomplate/tasks/install.yml @@ -10,8 +10,9 @@ url: https://github.com/hairyhenderson/gomplate/releases/latest return_content: false register: __manala_gomplate_version_latest - when: (not __manala_gomplate_bin_stat_result.stat.exists) - and (manala_gomplate_version is none) + when: + - not __manala_gomplate_bin_stat_result.stat.exists + - manala_gomplate_version is none - name: install > Install get_url: @@ -21,11 +22,11 @@ manala_gomplate_version, __manala_gomplate_version_latest.url|default|regex_replace('.+/v(\\d+\\.\\d+\\.\\d+)$', '\\1') ), - architecture=ansible_architecture|manala_gomplate_architecture, + architecture=ansible_architecture|manala.roles.gomplate_architecture, ) }}" dest: "{{ manala_gomplate_bin }}" owner: root group: root mode: "0755" - when: (not __manala_gomplate_bin_stat_result.stat.exists) + when: not __manala_gomplate_bin_stat_result.stat.exists diff --git a/roles/gomplate/tests/.gitignore b/roles/gomplate/tests/.gitignore deleted file mode 100644 index a8b42eb6e..000000000 --- a/roles/gomplate/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.retry diff --git a/roles/gomplate/tests/0000_default.goss.yml b/roles/gomplate/tests/0000_default.goss.yml deleted file mode 100644 index 5f62d358d..000000000 --- a/roles/gomplate/tests/0000_default.goss.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- - -file: - /usr/local/bin/gomplate: - exists: true - filetype: file - owner: root - group: root - mode: "0755" - -command: - gomplate --version: - exit-status: 0 - stdout: - - gomplate version diff --git a/roles/gomplate/tests/0000_default.yml b/roles/gomplate/tests/0000_default.yml deleted file mode 100644 index b6f135a4c..000000000 --- a/roles/gomplate/tests/0000_default.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - - block: - - import_role: - name: gomplate - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml validate diff --git a/roles/gomplate/tests/0100_install.goss.yml b/roles/gomplate/tests/0100_install.goss.yml deleted file mode 100644 index c2adc91b3..000000000 --- a/roles/gomplate/tests/0100_install.goss.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- - -# Version -{{ if has "version" .Vars.tags }} -file: - /usr/local/bin/gomplate: - exists: true - filetype: file - owner: root - group: root - mode: "0755" -command: - gomplate --version: - exit-status: 0 - stdout: - - gomplate version 3.6.0 -{{ end }} diff --git a/roles/gomplate/tests/0100_install.yml b/roles/gomplate/tests/0100_install.yml deleted file mode 100644 index 1319362a8..000000000 --- a/roles/gomplate/tests/0100_install.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- - -- name: "{{ test }}" - hosts: debian - become: true - tasks: - - # Version - - tags: [version] - block: - - file: - path: /usr/local/bin/gomplate - state: absent - - import_role: - name: gomplate - tasks_from: install - vars: - manala_gomplate_version: 3.6.0 - always: - - name: Goss - command: > - goss --gossfile {{ test }}.goss.yml --vars-inline "{tags: [version]}" validate diff --git a/roles/grafana/.gitignore b/roles/grafana/.gitignore deleted file mode 100644 index 345b1e317..000000000 --- a/roles/grafana/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.cache/ -.env diff --git a/roles/grafana/.manala/make/Makefile b/roles/grafana/.manala/make/Makefile deleted file mode 100644 index b800b7238..000000000 --- a/roles/grafana/.manala/make/Makefile +++ /dev/null @@ -1,223 +0,0 @@ -.PHONY: sh update lint test - -########## -# Manala # -########## - -MANALA_MAKE_DIR := $(abspath $(patsubst %/Makefile,%,$(lastword $(MAKEFILE_LIST)))) - -include \ - $(MANALA_MAKE_DIR)/Makefile.manala \ - $(MANALA_MAKE_DIR)/Makefile.docker \ - $(MANALA_MAKE_DIR)/Makefile.host \ - $(MANALA_MAKE_DIR)/Makefile.travis - --include \ - $(MANALA_CURRENT_DIR)/../.env \ - $(MANALA_CURRENT_DIR)/.env - -MANALA_VERBOSE := $(if $(VERBOSE),$(VERBOSE),$(MANALA_VERBOSE)) - -######## -# Role # -######## - -ROLE_DIR := $(MANALA_CURRENT_DIR) -ROLE_TESTS_DIR := $(ROLE_DIR)/tests - -################ -# Distribution # -################ - -DISTRIBUTION_ID = $(call list_split_first,.,$(DISTRIBUTION)) -DISTRIBUTION_RELEASE = $(call list_split_last,.,$(DISTRIBUTION)) - -########## -# Docker # -########## - -MANALA_DOCKER_IMAGE = manala/test-ansible -MANALA_DOCKER_IMAGE_TAG = $(if $(ANSIBLE_VERSION),$(ANSIBLE_VERSION)-)$(DISTRIBUTION) -MANALA_DOCKER_MOUNT_DIR = $(if $(ROLE_MOUNT_DIR),$(ROLE_MOUNT_DIR),/srv/role) -MANALA_DOCKER_HOST = $(ROLE).$(DISTRIBUTION).test -MANALA_DOCKER_RUN_OPTIONS = --privileged -MANALA_DOCKER_VOLUMES = \ - $(ROLE_DIR):/etc/ansible/roles/$(ROLE) \ - $(if $(CACHE_DIR), \ - $(call if_in,$(DISTRIBUTION_ID),debian, \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/archives:/var/cache/apt/archives \ - $(CACHE_DIR)/$(DISTRIBUTION_ID)/$(DISTRIBUTION_RELEASE)/apt/lists:/var/lib/apt/lists \ - ) \ - ) -MANALA_DOCKER_ENV = \ - USER_ID=$(MANALA_USER_ID) \ - GROUP_ID=$(MANALA_GROUP_ID) \ - MANALA_HOST=test \ - MANALA_VERBOSE=$(MANALA_VERBOSE) \ - DISTRIBUTION=$(DISTRIBUTION) \ - DISTRIBUTION_ID=$(DISTRIBUTION_ID) \ - DISTRIBUTION_RELEASE=$(DISTRIBUTION_RELEASE) \ - ANSIBLE_ACTION_PLUGINS=/srv/role/action_plugins \ - ANSIBLE_BECOME_FLAGS="$(call escape_spaces,-H -S -n -E)" \ - ANSIBLE_RETRY_FILES_ENABLED=0 \ - ANSIBLE_FORCE_COLOR=1 - -###### -# Sh # -###### - -MANALA_HELP += $(call if_host,local,$(SH_HELP)\n) - -SH_HELP = \ - $(call help_section,Test host shell) - -sh: .fail_if_host_not(local) - $(call fail_if_not,$(DISTRIBUTION),DISTRIBUTION is empty or not set) - $(call if_in,$(DISTRIBUTION),$(ROLE_DISTRIBUTIONS), \ - $(call docker_shell), \ - $(call log_warning,Shell on \"$(DISTRIBUTION)\" is not supported) \ - ) - -SH_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.jessie, Open shell on test host - Debian Jessie)) -sh.debian.jessie: DISTRIBUTION = debian.jessie -sh.debian.jessie: sh - -SH_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.stretch,Open shell on test host - Debian Stretch)) -sh.debian.stretch: DISTRIBUTION = debian.stretch -sh.debian.stretch: sh - -SH_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,sh.debian.buster, Open shell on test host - Debian Buster)) -sh.debian.buster: DISTRIBUTION = debian.buster -sh.debian.buster: sh - -########## -# Update # -########## - -MANALA_HELP += $(call if_host,local,$(UPDATE_HELP)\n) - -UPDATE_HELP = \ - $(call help_section,Test host update) \ - $(call help,update, Update test hosts across distributions) - -update: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Update \"$$(DISTRIBUTION)\") ; \ - $$(call docker_pull), \ - $$(call log_warning,Update \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -UPDATE_HELP += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.jessie, Update test host - Debian Jessie)) -update.debian.jessie: DISTRIBUTIONS = debian.jessie -update.debian.jessie: update - -UPDATE_HELP += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.stretch,Update test host - Debian Stretch)) -update.debian.stretch: DISTRIBUTIONS = debian.stretch -update.debian.stretch: update - -UPDATE_HELP += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,update.debian.buster, Update test host - Debian Buster)) -update.debian.buster: DISTRIBUTIONS = debian.buster -update.debian.buster: update - -######## -# Lint # -######## - -MANALA_HELP += $(call if_host,local,$(LINT_HELP_LOCAL)\n,$(LINT_HELP_TEST)\n) - -LINT_HELP = $(call help_section,Lint) -LINT_HELP_LOCAL = $(LINT_HELP) \ - $(call help,lint, Lint role across distributions) -LINT_HELP_TEST = $(LINT_HELP) \ - $(call help,lint,Lint role) - -lint: .host_switch(lint) - -lint@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call docker_make,lint@test), \ - $$(call log_warning,Lint \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -lint@test: .fail_if_host_not(test) - ansible-lint --force-color -v $(ROLE_DIR) - -LINT_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.jessie, Lint role - Debian Jessie)) -lint.debian.jessie: DISTRIBUTIONS = debian.jessie -lint.debian.jessie: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.stretch,Lint role - Debian Stretch)) -lint.debian.stretch: DISTRIBUTIONS = debian.stretch -lint.debian.stretch: lint@local - -LINT_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,lint.debian.buster, Lint role - Debian Buster)) -lint.debian.buster: DISTRIBUTIONS = debian.buster -lint.debian.buster: lint@local - -######## -# Test # -######## - -TESTS = $(sort \ - $(foreach \ - TEST, \ - $(wildcard $(ROLE_TESTS_DIR)/*.yml), \ - $(if $(findstring .goss.,$(TEST)),, \ - $(patsubst /%,%,$(subst $(ROLE_DIR),,$(TEST))) \ - ) \ - ) \ -) - -tests/%.yml: FORCE - $(call verbose, ,ANSIBLE_STDOUT_CALLBACK=actionable,ANSIBLE_STDOUT_CALLBACK=debug) \ - ansible-playbook $@ \ - --extra-vars="test=$(subst .yml,,$(subst tests/,,$@))" \ - $(if $(CHECK),--check --diff) \ - $(if $(TAGS),--tags=$(TAGS)) -FORCE: - -MANALA_HELP += $(call if_host,local,$(TEST_HELP_LOCAL),$(TEST_HELP_TEST)) - -TEST_HELP = $(call help_section,Test) -TEST_HELP_LOCAL = $(TEST_HELP) \ - $(call help,test, Test role across distributions) -TEST_HELP_BUILD = $(TEST_HELP) \ - $(call help,test,Test role) - -test: .host_switch(test) - -test@local: .fail_if_host_not(local) - $(call list_loop,DISTRIBUTION,$(if $(DISTRIBUTIONS),$(DISTRIBUTIONS),$(ROLE_DISTRIBUTIONS)), \ - $$(call if_in,$$(DISTRIBUTION),$$(ROLE_DISTRIBUTIONS), \ - $$(call log,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\") ; \ - $$(call list_loop,TEST,$$(TESTS), \ - $$$$(call log, $$$$(TEST)) ; \ - $$$$(call docker_make,$$$$(TEST)), \ - TRAVIS_FOLD \ - ), \ - $$(call log_warning,Test \"$$(ROLE)\" on \"$$(DISTRIBUTION)\" is not supported) \ - ) \ - ) - -test@test: .fail_if_host_not(test) - $(call list_loop,TEST,$(TESTS), \ - $$(call log,Test \"$$(TEST)\") ; \ - $$(MAKE) $$(TEST) \ - ) - -TEST_HELP_LOCAL += $(call if_in,debian.jessie,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.jessie, Test role - Debian Jessie)) -test.debian.jessie: DISTRIBUTIONS = debian.jessie -test.debian.jessie: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.stretch,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.stretch,Test role - Debian Stretch)) -test.debian.stretch: DISTRIBUTIONS = debian.stretch -test.debian.stretch: test@local - -TEST_HELP_LOCAL += $(call if_in,debian.buster,$(ROLE_DISTRIBUTIONS),$(call help,test.debian.buster, Test role - Debian Buster)) -test.debian.buster: DISTRIBUTIONS = debian.buster -test.debian.buster: test@local diff --git a/roles/grafana/.manala/make/Makefile.docker b/roles/grafana/.manala/make/Makefile.docker deleted file mode 100644 index aad1c1d95..000000000 --- a/roles/grafana/.manala/make/Makefile.docker +++ /dev/null @@ -1,54 +0,0 @@ -############# -# Functions # -############# - -define docker_run - docker run \ - --rm \ - $(if $(MANALA_DOCKER_MOUNT_DIR), \ - --volume $(MANALA_CURRENT_DIR):$(MANALA_DOCKER_MOUNT_DIR) \ - --workdir $(MANALA_DOCKER_MOUNT_DIR) \ - ) \ - $(if $(MANALA_INTERACTIVE),--tty --interactive) \ - $(if $(MANALA_DOCKER_HOST),--hostname $(MANALA_DOCKER_HOST)) \ - $(if $(MANALA_DOCKER_VOLUMES), \ - $(foreach \ - VOLUME,\ - $(MANALA_DOCKER_VOLUMES),\ - --volume $(VOLUME) \ - ) \ - ) \ - $(if $(MANALA_DOCKER_ENV), \ - $(foreach \ - ENV,\ - $(call encode_spaces,$(MANALA_DOCKER_ENV)),\ - --env $(call decode_spaces,$(ENV)) \ - ) \ - ) \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_RUN_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) \ - $(1) -endef - -define docker_shell - $(call docker_run) -endef - -define docker_make - $(call docker_run,sh -c "make --silent --directory=$(MANALA_DOCKER_MOUNT_DIR) $(1)") -endef - -define docker_pull - docker pull \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_PULL_OPTIONS) \ - $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef - -define docker_build - docker build \ - $(MANALA_DOCKER_OPTIONS) \ - $(MANALA_DOCKER_BUILD_OPTIONS) \ - --tag $(MANALA_DOCKER_IMAGE):$(if $(MANALA_DOCKER_IMAGE_TAG),$(MANALA_DOCKER_IMAGE_TAG),latest) -endef diff --git a/roles/grafana/.manala/make/Makefile.host b/roles/grafana/.manala/make/Makefile.host deleted file mode 100644 index 61996d283..000000000 --- a/roles/grafana/.manala/make/Makefile.host +++ /dev/null @@ -1,33 +0,0 @@ -######## -# Host # -######## - -MANALA_HOST ?= local - -# Usage: -# target: .fail_if_host_not(local) -# # Do something on local host... - -.fail_if_host_not(%): - $(call fail_if_host_not,$(*)) - -define fail_if_host_not -$(call if_eq,$(1),$(MANALA_HOST),,$(call message_error,Must be run on \"$(1)\" host); exit 1) -endef - -# Usage: -# $(call if_host,local,Yes,No) = Yes - -define if_host -$(call if_eq,$(1),$(MANALA_HOST),$(2),$(3)) -endef - -.host_switch(%): - $(call host_switch,$(*)) - -# Usage: -# $(call host_switch,target) => make target@[host] - -define host_switch -$(MAKE) $(1)@$(MANALA_HOST) -endef diff --git a/roles/grafana/.manala/make/Makefile.manala b/roles/grafana/.manala/make/Makefile.manala deleted file mode 100644 index 5864492a9..000000000 --- a/roles/grafana/.manala/make/Makefile.manala +++ /dev/null @@ -1,401 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: help manala - -############################# -# GNU Make Standard Library # -############################# - -include $(MANALA_MAKE_DIR)/gmsl/gmsl - -############### -# Directories # -############### - -MANALA_DIR := $(patsubst %/make,%,$(MANALA_MAKE_DIR)) -MANALA_CURRENT_DIR := $(CURDIR) - -########### -# Contact # -########### - -MANALA_CONTACT = $(MANALA_CONTACT_NAME) <$(MANALA_CONTACT_MAIL)> -MANALA_CONTACT_NAME := Manala -MANALA_CONTACT_MAIL := contact@manala.io - -########## -# Colors # -########## - -MANALA_COLOR_RESET := \033[0m -MANALA_COLOR_ERROR := \033[31m -MANALA_COLOR_INFO := \033[32m -MANALA_COLOR_WARNING := \033[33m -MANALA_COLOR_COMMENT := \033[36m - -######## -# Help # -######## - -define help_section - \n$(MANALA_COLOR_COMMENT)$(1):$(MANALA_COLOR_RESET) -endef - -define help - \n $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET) $(2) -endef - -MANALA_HELP = \ - \nUsage: make [$(MANALA_COLOR_INFO)target$(MANALA_COLOR_RESET)]\n\ - $(call help_section,Help)\ - $(call help,help,This help)\ - \n - -help: - @printf "$(MANALA_HELP)" -ifneq ($(MANALA_CURRENT_DIR),$(MANALA_DIR)) - @awk '/^[a-zA-Z\-\_0-9\.@%]+:/ { \ - helpMessage = match(lastLine, /^## (.*)/); \ - if (helpMessage) { \ - helpCommand = substr($$1, 0, index($$1, ":")); \ - helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \ - printf "\n $(MANALA_COLOR_INFO)%-20s$(MANALA_COLOR_RESET) %s", helpCommand, helpMessage; \ - } \ - } \ - { lastLine = $$0 }' $(MAKEFILE_LIST) -endif - @printf "\n\n" - -################ -# User / Group # -################ - -MANALA_USER_ID := $(shell id -u) -MANALA_GROUP_ID := $(shell id -g) - -############### -# Interactive # -############### - -MANALA_INTERACTIVE := $(shell [ -t 0 ] && echo 1) - -############### -# Date / Time # -############### - -# Usage: -# $(call time) = 11:06:20 -# $(call date_nano) = 1504443855143518510 - -define time -`date -u +%T` -endef - -ifeq ($(shell uname -s),Darwin) -define date_nano -`date -u +%s000000000` -endef -else -define date_nano -`date -u +%s%N` -endef -endif - -########### -# Verbose # -########### - -# 0: Nothing -# 1: Nothing but errors and logs -# 2: Normal -# 3: Verbose -MANALA_VERBOSE ?= 2 - -# Usage: -# [MANALA_VERBOSE = 0] -# $(call verbose,foo,bar) = foo -# $(call verbose,foo) = foo -# [MANALA_VERBOSE = 1] -# $(call verbose,foo,bar) = bar -# $(call verbose,foo,) = -# $(call verbose,foo) = foo - -define verbose -$(call if_eq,$(MANALA_VERBOSE),0,$(1),$(call if_eq,$(MANALA_VERBOSE),1,$(if $(2),$(2),$(1)),$(call if_eq,$(MANALA_VERBOSE),2,$(if $(3),$(3),$(if $(2),$(2),$(1))),$(if $(4),$(4),$(if $(3),$(3),$(if $(2),$(2),$(1))))))) -endef - -################# -# Message / Log # -################# - -# Usage: -# $(call message,Foo bar) = Foo bar -# $(call message_warning,Foo bar) = ¯\_(ツ)_/¯ Foo bar -# $(call message_error,Foo bar) = (╯°□°)╯︵ â”»â”â”» Foo bar -# $(call log,Foo bar) = [11:06:20] [target] Foo bar -# $(call log_warning,Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar -# $(call log_error,Foo bar) = [11:06:20] [target] (╯°□°)╯︵ â”»â”â”» Foo bar - -define message - $(call verbose,:,printf "$(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_warning - $(call verbose,:,printf "$(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define message_error - $(call verbose,:,printf "$(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_INFO)$(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_warning - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_WARNING)¯\_(ツ)_/¯ $(1)$(MANALA_COLOR_RESET)\n") -endef - -define log_error - $(call verbose,:,printf "[$(MANALA_COLOR_COMMENT)$(call time)$(MANALA_COLOR_RESET)] [$(MANALA_COLOR_COMMENT)$(@)$(MANALA_COLOR_RESET)] $(MANALA_COLOR_ERROR)(╯°□°)╯︵ â”»â”â”» $(1)$(MANALA_COLOR_RESET)\n") -endef - -###################### -# Special Characters # -###################### - -# Hide special characters from Make's parser -# See: http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html - -, := , -space := -space += -$(space) := -$(space) += - -# Usage: -# $(call escape_spaces,foo bar) = foo\ bar -# $(call unescape_spaces,foo\ bar) = foo bar -# $(call encode_spaces,foo\ bar) = fooâ£bar -# $(call decode_spaces,fooâ£bar) = foo bar - -define escape_spaces -$(subst $( ),\ ,$(1)) -endef - -define unescape_spaces -$(subst \ ,$( ),$(1)) -endef - -define encode_spaces -$(subst \ ,â£,$(1)) -endef - -define decode_spaces -$(subst â£, ,$(1)) -endef - -######## -# Fail # -######## - -define fail_if_not - $(if $(1),,$(call message_error,$(2)); exit 1) -endef - -define fail_if_not_in - $(call if_in,$(1),$(2),,$(call message_error,$(3)); exit 1) -endef - -########### -# Confirm # -########### - -define confirm - printf "\n$(MANALA_COLOR_INFO) ༼ 㤠◕_â—• ༽㤠$(MANALA_COLOR_WARNING)$(1) (y/N)$(MANALA_COLOR_RESET): "; \ - read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \ - printf "\n" -endef - -###### -# If # -###### - -# If element in list list - -# Usage: -# $(call if_in,foo,foo bar baz,Yes,No) = Yes -# $(call if_in,qux,foo bar baz,Yes,No) = No - -define if_in -$(if $(call set_is_member,$(1),$(2)),$(3),$(4)) -endef - -# If equal - -# Usage: -# $(call if_eq,1,1,Yes,No) = Yes -# $(call if_eq,1,2,Yes,No) = No - -define if_eq -$(if $(call seq,$(1),$(2)),$(3),$(4)) -endef - -# If number greater than or equal - -# Usage: -# $(call if_gte,1,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = Yes -# $(call if_gte,2,1,Yes,No) = No - -define if_gte -$(if $(call gte,$(1),$(2)),$(3),$(4)) -endef - -######## -# List # -######## - -# Returns the list with duplicate elements removed without reordering -# Usage: -# $(call list_uniq,foo bar bar baz) = foo bar - -define list_uniq -$(call uniq,$(1)) -endef - -# Splits a string into a list separated by spaces at the split character in the first argument -# Usage: -# $(call list_split,:,foo:bar) = foo bar - -define list_split -$(call split,$(1),$(2)) -endef - -# Usage: -# $(call list_split_first,:,foo:bar) = foo - -define list_split_first -$(call list_first,$(call list_split,$(1),$(2))) -endef - -# Usage: -# $(call list_split_last,:,foo:bar) = bar - -define list_split_last -$(call list_last,$(call list_split,$(1),$(2))) -endef - -# Returns the first element of a list -# Usage: -# $(call list_first,foo bar) = foo - -define list_first -$(call first,$(1)) -endef - -# Returns the last element of a list -# Usage: -# $(call list_last,foo bar) = bar - -define list_last -$(call last,$(1)) -endef - -# Returns the list with the first element removed -# Usage: -# $(call list_rest,foo bar baz) = bar baz - -define list_rest -$(call rest,$(1)) -endef - -# Returns the list with the last element removed -# Usage: -# $(call list_chop,foo bar baz) = foo bar - -define list_chop -$(call chop,$(1)) -endef - -# Usage: -# $(call list_loop,ITEM,foo bar baz,echo $$(ITEM)) = foo\nbar\nbaz\n - -define list_loop - ( MANALA_LIST_LOOP_EXIT=0 ; \ - $(foreach \ - $(1), \ - $(2), \ - MANALA_LIST_LOOP_ITEM=$($(1)) ; \ - $(foreach MANALA_LIST_LOOP_START_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_START_$(MANALA_LIST_LOOP_START_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ( $(eval MANALA_LIST_LOOP := $(3)) $(MANALA_LIST_LOOP) ) ; \ - MANALA_LIST_LOOP_ITEM_EXIT=$${?} ; MANALA_LIST_LOOP_EXIT=$$(($${MANALA_LIST_LOOP_EXIT} || $${MANALA_LIST_LOOP_ITEM_EXIT})) ; \ - $(foreach MANALA_LIST_LOOP_END_HOOK,$(4),$(eval MANALA_LIST_LOOP_HOOK = $(value MANALA_LIST_LOOP_HOOK_END_$(MANALA_LIST_LOOP_END_HOOK))) $(MANALA_LIST_LOOP_HOOK)) \ - ) \ - [ $${MANALA_LIST_LOOP_EXIT} -eq 0 ] ) -endef - -MANALA_LIST_LOOP_HOOK_START_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop start \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; -MANALA_LIST_LOOP_HOOK_END_DEBUG = printf "$(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Loop stop \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET) Exit \"$(MANALA_COLOR_INFO)$${MANALA_LIST_LOOP_ITEM_EXIT}$(MANALA_COLOR_RESET)\" $(MANALA_COLOR_COMMENT)===$(MANALA_COLOR_RESET)\n" ; - -# Usage: -# $(call list_partition,1,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = aaa zzz eee -# $(call list_partition,2,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = rrr ttt yyy -# $(call list_partition,3,3,aaa zzz eee rrr ttt yyy uuu iii ooo ppp) = uuu iii ooo ppp - -define list_partition -$(wordlist $(call list_partition_index,$(1),$(2),$(words $(3))),$(call plus,$(call list_partition_index,$(1),$(2),$(words $(3))),$(call list_partition_size,$(1),$(2),$(words $(3)))),$(3)) -endef - -define list_partition_index -$(call if_gte,$(3),$(2),$(call plus,$(call multiply,$(call subtract,$(1),1),$(call divide,$(3),$(2))),1),$(1)) -endef - -define list_partition_size -$(call if_eq,$(1),$(2),$(3),$(call subtract,$(call if_gte,$(3),$(2),$(call divide,$(3),$(2)),1,),1)) -endef - -########## -# Semver # -########## - -# Usage: -# $(call semver_major,3.2.1) = 3 - -define semver_major -$(call list_first,$(call list_split,.,$(1))) -endef - -# Usage: -# $(call semver_minor,3.2.1) = 2 - -define semver_minor -$(call list_first,$(call list_rest,$(call list_split,.,$(1)))) -endef - -# Usage: -# $(call semver_patch,3.2.1) = 1 - -define semver_patch -$(call list_last,$(call list_split,.,$(1))) -endef - - -######## -# Rand # -######## - -# Usage: -# $(call rand) = 51088 -# $(call rand) = 49478 -# ... - -define rand -`od -An -N2 -i /dev/random | tr -d ' '` -endef - -########## -# Manala # -########## - -manala: - @curl -s -L http://bit.ly/10hA8iC | bash diff --git a/roles/grafana/.manala/make/Makefile.travis b/roles/grafana/.manala/make/Makefile.travis deleted file mode 100644 index df307b6c8..000000000 --- a/roles/grafana/.manala/make/Makefile.travis +++ /dev/null @@ -1,19 +0,0 @@ -############### -# List - Loop # -############### - -MANALA_LIST_LOOP_HOOK_START_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_FOLD=`echo $${MANALA_LIST_LOOP_ITEM} | sed -E 's/[^-_A-Za-z0-9]+/./g'` ; \ - printf "travis_fold:start:$${MANALA_TRAVIS_FOLD}\n" ; \ - MANALA_TRAVIS_TIME_ID=$(call rand) ; \ - MANALA_TRAVIS_TIME_START=$(call date_nano) ; \ - printf "travis_time:start:$${MANALA_TRAVIS_TIME_ID}\n" ; \ -) - -MANALA_LIST_LOOP_HOOK_END_TRAVIS_FOLD = $(if $(TRAVIS), \ - MANALA_TRAVIS_TIME_FINISH=$(call date_nano) ; \ - printf "travis_time:end:$${MANALA_TRAVIS_TIME_ID}:start=$${MANALA_TRAVIS_TIME_START}$(,)finish=$${MANALA_TRAVIS_TIME_FINISH}$(,)duration=$$(($${MANALA_TRAVIS_TIME_FINISH}-$${MANALA_TRAVIS_TIME_START}))\n" ; \ - if [ $${MANALA_LIST_LOOP_ITEM_EXIT} -eq 0 ]; then \ - printf "travis_fold:end:$${MANALA_TRAVIS_FOLD}\n" ; \ - fi ; \ -) diff --git a/roles/grafana/.manala/make/gmsl/__gmsl b/roles/grafana/.manala/make/gmsl/__gmsl deleted file mode 100644 index 3db20ad91..000000000 --- a/roles/grafana/.manala/make/gmsl/__gmsl +++ /dev/null @@ -1,940 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# This is the GNU Make Standard Library version number as a list with -# three items: major, minor, revision - -gmsl_version := 1 1 7 - -__gmsl_name := GNU Make Standard Library - -# Used to output warnings and error from the library, it's possible to -# disable any warnings or errors by overriding these definitions -# manually or by setting GMSL_NO_WARNINGS or GMSL_NO_ERRORS - -ifdef GMSL_NO_WARNINGS -__gmsl_warning := -else -__gmsl_warning = $(if $1,$(warning $(__gmsl_name): $1)) -endif - -ifdef GMSL_NO_ERRORS -__gmsl_error := -else - __gmsl_error = $(if $1,$(error $(__gmsl_name): $1)) -endif - -# If GMSL_TRACE is enabled then calls to the library functions are -# traced to stdout using warning messages with their arguments - -ifdef GMSL_TRACE -__gmsl_tr1 = $(warning $0('$1')) -__gmsl_tr2 = $(warning $0('$1','$2')) -__gmsl_tr3 = $(warning $0('$1','$2','$3')) -else -__gmsl_tr1 := -__gmsl_tr2 := -__gmsl_tr3 := -endif - -# See if spaces are valid in variable names (this was the case until -# GNU Make 3.82) -ifeq ($(MAKE_VERSION),3.82) -__gmsl_spaced_vars := $(false) -else -__gmsl_spaced_vars := $(true) -endif - -# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) -# if we do not then output a warning message, if we do then some -# functions will be enabled. - -__gmsl_have_eval := $(false) -__gmsl_ignore := $(eval __gmsl_have_eval := $(true)) - -# If this is being run with Electric Cloud's emake then warn that -# their $(eval) support is incomplete in 1.x, 2.x, 3.x, 4.x and 5.0, -# 5.1, 5.2 and 5.3 - -ifdef ECLOUD_BUILD_ID -__gmsl_emake_major := $(word 1,$(subst ., ,$(EMAKE_VERSION))) -__gmsl_emake_minor := $(word 2,$(subst ., ,$(EMAKE_VERSION))) -ifneq ("$(findstring $(__gmsl_emake_major),1 2 3 4)$(findstring $(__gmsl_emake_major)$(__gmsl_emake_minor),50 51 52 53)","") -$(warning You are using a version of Electric Cloud's emake which has incomplete $$(eval) support) -__gmsl_have_eval := $(false) -endif -endif - -# See if we have $(lastword) (GNU Make 3.81 and above) - -__gmsl_have_lastword := $(lastword $(false) $(true)) - -# See if we have native or and and (GNU Make 3.81 and above) - -__gmsl_have_or := $(if $(filter-out undefined, \ - $(origin or)),$(call or,$(true),$(false))) -__gmsl_have_and := $(if $(filter-out undefined, \ - $(origin and)),$(call and,$(true),$(true))) - -ifneq ($(__gmsl_have_eval),$(true)) -$(call __gmsl_warning,Your make version $(MAKE_VERSION) does not support $$$$(eval): some functions disabled) -endif - -__gmsl_dollar := $$ -__gmsl_hash := \# - -# ---------------------------------------------------------------------------- -# ---------------------------------------------------------------------------- -# Function: gmsl_compatible -# Arguments: List containing the desired library version number (maj min rev) -# Returns: $(true) if this version of the library is compatible -# with the requested version number, otherwise $(false) -# ---------------------------------------------------------------------------- -gmsl_compatible = $(strip \ - $(if $(call gt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 1,$1),$(word 1,$(gmsl_version))), \ - $(true), \ - $(if $(call gt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(false), \ - $(if $(call lt,$(word 2,$1),$(word 2,$(gmsl_version))), \ - $(true), \ - $(call lte,$(word 3,$1),$(word 3,$(gmsl_version)))))))) - -# ########################################################################### -# LOGICAL OPERATORS -# ########################################################################### - -# not is defined in gmsl - -# ---------------------------------------------------------------------------- -# Function: and -# Arguments: Two boolean values -# Returns: Returns $(true) if both of the booleans are true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_and),$(true)) -and = $(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: or -# Arguments: Two boolean values -# Returns: Returns $(true) if either of the booleans is true -# ---------------------------------------------------------------------------- -ifneq ($(__gmsl_have_or),$(true)) -or = $(__gmsl_tr2)$(if $1$2,$(true),$(false)) -endif - -# ---------------------------------------------------------------------------- -# Function: xor -# Arguments: Two boolean values -# Returns: Returns $(true) if exactly one of the booleans is true -# ---------------------------------------------------------------------------- -xor = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(if $2,$(true),$(false))) - -# ---------------------------------------------------------------------------- -# Function: nand -# Arguments: Two boolean values -# Returns: Returns value of 'not and' -# ---------------------------------------------------------------------------- -nand = $(__gmsl_tr2)$(if $1,$(if $2,$(false),$(true)),$(true)) - -# ---------------------------------------------------------------------------- -# Function: nor -# Arguments: Two boolean values -# Returns: Returns value of 'not or' -# ---------------------------------------------------------------------------- -nor = $(__gmsl_tr2)$(if $1$2,$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: xnor -# Arguments: Two boolean values -# Returns: Returns value of 'not xor' -# ---------------------------------------------------------------------------- -xnor =$(__gmsl_tr2)$(if $1,$(if $2,$(true),$(false)),$(if $2,$(false),$(true))) - -# ########################################################################### -# LIST MANIPULATION FUNCTIONS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: first (same as LISP's car, or head) -# Arguments: 1: A list -# Returns: Returns the first element of a list -# ---------------------------------------------------------------------------- -first = $(__gmsl_tr1)$(firstword $1) - -# ---------------------------------------------------------------------------- -# Function: last -# Arguments: 1: A list -# Returns: Returns the last element of a list -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_have_lastword),$(true)) -last = $(__gmsl_tr1)$(lastword $1) -else -last = $(__gmsl_tr1)$(if $1,$(word $(words $1),$1)) -endif - -# ---------------------------------------------------------------------------- -# Function: rest (same as LISP's cdr, or tail) -# Arguments: 1: A list -# Returns: Returns the list with the first element removed -# ---------------------------------------------------------------------------- -rest = $(__gmsl_tr1)$(wordlist 2,$(words $1),$1) - -# ---------------------------------------------------------------------------- -# Function: chop -# Arguments: 1: A list -# Returns: Returns the list with the last element removed -# ---------------------------------------------------------------------------- -chop = $(__gmsl_tr1)$(wordlist 2,$(words $1),x $1) - -# ---------------------------------------------------------------------------- -# Function: map -# Arguments: 1: Name of function to $(call) for each element of list -# 2: List to iterate over calling the function in 1 -# Returns: The list after calling the function on each element -# ---------------------------------------------------------------------------- -map = $(__gmsl_tr2)$(strip $(foreach a,$2,$(call $1,$a))) - -# ---------------------------------------------------------------------------- -# Function: pairmap -# Arguments: 1: Name of function to $(call) for each pair of elements -# 2: List to iterate over calling the function in 1 -# 3: Second list to iterate over calling the function in 1 -# Returns: The list after calling the function on each pair of elements -# ---------------------------------------------------------------------------- -pairmap = $(strip $(__gmsl_tr3)\ - $(if $2$3,$(call $1,$(call first,$2),$(call first,$3)) \ - $(call pairmap,$1,$(call rest,$2),$(call rest,$3)))) - -# ---------------------------------------------------------------------------- -# Function: leq -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are identical -# ---------------------------------------------------------------------------- -leq = $(__gmsl_tr2)$(strip $(if $(call seq,$(words $1),$(words $2)), \ - $(call __gmsl_list_equal,$1,$2),$(false))) - -__gmsl_list_equal = $(if $(strip $1), \ - $(if $(call seq,$(call first,$1),$(call first,$2)), \ - $(call __gmsl_list_equal, \ - $(call rest,$1), \ - $(call rest,$2)), \ - $(false)), \ - $(true)) - -# ---------------------------------------------------------------------------- -# Function: lne -# Arguments: 1: A list to compare against... -# 2: ...this list -# Returns: Returns $(true) if the two lists are different -# ---------------------------------------------------------------------------- -lne = $(__gmsl_tr2)$(call not,$(call leq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: reverse -# Arguments: 1: A list to reverse -# Returns: The list with its elements in reverse order -# ---------------------------------------------------------------------------- -reverse =$(__gmsl_tr1)$(strip $(if $1,$(call reverse,$(call rest,$1)) \ - $(call first,$1))) - -# ---------------------------------------------------------------------------- -# Function: uniq -# Arguments: 1: A list from which to remove repeated elements -# Returns: The list with duplicate elements removed without reordering -# ---------------------------------------------------------------------------- -uniq = $(strip $(__gmsl_tr1) $(if $1,$(firstword $1) \ - $(call uniq,$(filter-out $(firstword $1),$1)))) - -# ---------------------------------------------------------------------------- -# Function: length -# Arguments: 1: A list -# Returns: The number of elements in the list -# ---------------------------------------------------------------------------- -length = $(__gmsl_tr1)$(words $1) - -# ########################################################################### -# STRING MANIPULATION FUNCTIONS -# ########################################################################### - -# Helper function that translates any GNU Make 'true' value (i.e. a -# non-empty string) to our $(true) - -__gmsl_make_bool = $(if $(strip $1),$(true),$(false)) - -# ---------------------------------------------------------------------------- -# Function: seq -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are identical -# ---------------------------------------------------------------------------- -seq = $(__gmsl_tr2)$(if $(subst x$1,,x$2)$(subst x$2,,x$1),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: sne -# Arguments: 1: A string to compare against... -# 2: ...this string -# Returns: Returns $(true) if the two strings are not the same -# ---------------------------------------------------------------------------- -sne = $(__gmsl_tr2)$(call not,$(call seq,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: split -# Arguments: 1: The character to split on -# 2: A string to split -# Returns: Splits a string into a list separated by spaces at the split -# character in the first argument -# ---------------------------------------------------------------------------- -split = $(__gmsl_tr2)$(strip $(subst $1, ,$2)) - -# ---------------------------------------------------------------------------- -# Function: merge -# Arguments: 1: The character to put between fields -# 2: A list to merge into a string -# Returns: Merges a list into a single string, list elements are separated -# by the character in the first argument -# ---------------------------------------------------------------------------- -merge = $(__gmsl_tr2)$(strip $(if $2, \ - $(if $(call seq,1,$(words $2)), \ - $2,$(call first,$2)$1$(call merge,$1,$(call rest,$2))))) - -ifdef __gmsl_have_eval -# ---------------------------------------------------------------------------- -# Function: tr -# Arguments: 1: The list of characters to translate from -# 2: The list of characters to translate to -# 3: The text to translate -# Returns: Returns the text after translating characters -# ---------------------------------------------------------------------------- -tr = $(strip $(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3) \ - $(eval __gmsl_t := $3) \ - $(foreach c, \ - $(join $(addsuffix :,$1),$2), \ - $(eval __gmsl_t := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ - $(__gmsl_t))))$(__gmsl_t)) - -# Common character classes for use with the tr function. Each of -# these is actually a variable declaration and must be wrapped with -# $() or ${} to be used. - -[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # -[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # -[0-9] := 0 1 2 3 4 5 6 7 8 9 # -[A-F] := A B C D E F # - -# ---------------------------------------------------------------------------- -# Function: uc -# Arguments: 1: Text to upper case -# Returns: Returns the text in upper case -# ---------------------------------------------------------------------------- -uc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([a-z]),$([A-Z]),$1) - -# ---------------------------------------------------------------------------- -# Function: lc -# Arguments: 1: Text to lower case -# Returns: Returns the text in lower case -# ---------------------------------------------------------------------------- -lc = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(call tr,$([A-Z]),$([a-z]),$1) - -# ---------------------------------------------------------------------------- -# Function: strlen -# Arguments: 1: A string -# Returns: Returns the length of the string -# ---------------------------------------------------------------------------- - -# This results in __gmsl_tab containing a tab - -__gmsl_tab := # - -__gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -__gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z -__gmsl_characters += 0 1 2 3 4 5 6 7 8 9 -__gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = + -__gmsl_characters += { } [ ] \ : ; ' " < > , . / ? | - -# This results in __gmsl_space containing just a space - -__gmsl_space := -__gmsl_space += - -strlen = $(__gmsl_tr1)$(call assert_no_dollar,$0,$1)$(strip $(eval __temp := $(subst $(__gmsl_space),x,$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,x,$(__temp))))$(eval __temp := $(subst x,x ,$(__temp)))$(words $(__temp))) - -# This results in __gmsl_newline containing just a newline - -define __gmsl_newline - - -endef - -# ---------------------------------------------------------------------------- -# Function: substr -# Arguments: 1: A string -# 2: Start position (first character is 1) -# 3: End position (inclusive) -# Returns: A substring. -# Note: The string in $1 must not contain a § -# ---------------------------------------------------------------------------- - -substr = $(if $2,$(__gmsl_tr3)$(call assert_no_dollar,$0,$1$2$3)$(strip $(eval __temp := $$(subst $$(__gmsl_space),§ ,$$1))$(foreach a,$(__gmsl_characters),$(eval __temp := $$(subst $$a,$$a$$(__gmsl_space),$(__temp))))$(eval __temp := $(wordlist $2,$3,$(__temp))))$(subst §,$(__gmsl_space),$(subst $(__gmsl_space),,$(__temp)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# SET MANIPULATION FUNCTIONS -# ########################################################################### - -# Sets are represented by sorted, deduplicated lists. To create a set -# from a list use set_create, or start with the empty_set and -# set_insert individual elements - -# This is the empty set -empty_set := - -# ---------------------------------------------------------------------------- -# Function: set_create -# Arguments: 1: A list of set elements -# Returns: Returns the newly created set -# ---------------------------------------------------------------------------- -set_create = $(__gmsl_tr1)$(sort $1) - -# ---------------------------------------------------------------------------- -# Function: set_insert -# Arguments: 1: A single element to add to a set -# 2: A set -# Returns: Returns the set with the element added -# ---------------------------------------------------------------------------- -set_insert = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_remove -# Arguments: 1: A single element to remove from a set -# 2: A set -# Returns: Returns the set with the element removed -# ---------------------------------------------------------------------------- -set_remove = $(__gmsl_tr2)$(filter-out $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_member, set_is_not_member -# Arguments: 1: A single element -# 2: A set -# Returns: (set_is_member) Returns $(true) if the element is in the set -# (set_is_not_member) Returns $(false) if the element is in the set -# ---------------------------------------------------------------------------- -set_is_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(true),$(false)) -set_is_not_member = $(__gmsl_tr2)$(if $(filter $1,$2),$(false),$(true)) - -# ---------------------------------------------------------------------------- -# Function: set_union -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the union of the two sets -# ---------------------------------------------------------------------------- -set_union = $(__gmsl_tr2)$(sort $1 $2) - -# ---------------------------------------------------------------------------- -# Function: set_intersection -# Arguments: 1: A set -# 2: Another set -# Returns: Returns the intersection of the two sets -# ---------------------------------------------------------------------------- -set_intersection = $(__gmsl_tr2)$(filter $1,$2) - -# ---------------------------------------------------------------------------- -# Function: set_is_subset -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the first set is a subset of the second -# ---------------------------------------------------------------------------- -set_is_subset = $(__gmsl_tr2)$(call set_equal,$(call set_intersection,$1,$2),$1) - -# ---------------------------------------------------------------------------- -# Function: set_equal -# Arguments: 1: A set -# 2: Another set -# Returns: Returns $(true) if the two sets are identical -# ---------------------------------------------------------------------------- -set_equal = $(__gmsl_tr2)$(call seq,$1,$2) - -# ########################################################################### -# ARITHMETIC LIBRARY -# ########################################################################### - -# Integers a represented by lists with the equivalent number of x's. -# For example the number 4 is x x x x. - -# ---------------------------------------------------------------------------- -# Function: int_decode -# Arguments: 1: A number of x's representation -# Returns: Returns the integer for human consumption that is represented -# by the string of x's -# ---------------------------------------------------------------------------- -int_decode = $(__gmsl_tr1)$(words $1) - -# ---------------------------------------------------------------------------- -# Function: int_encode -# Arguments: 1: A number in human-readable integer form -# Returns: Returns the integer encoded as a string of x's -# ---------------------------------------------------------------------------- -__int_encode = $(if $1,$(if $(call seq,$(words $(wordlist 1,$1,$2)),$1),$(wordlist 1,$1,$2),$(call __int_encode,$1,$(if $2,$2 $2,x)))) -__strip_leading_zero = $(if $1,$(if $(call seq,$(patsubst 0%,%,$1),$1),$1,$(call __strip_leading_zero,$(patsubst 0%,%,$1))),0) -int_encode = $(__gmsl_tr1)$(call __int_encode,$(call __strip_leading_zero,$1)) - -# The arithmetic library functions come in two forms: one form of each -# function takes integers as arguments and the other form takes the -# encoded form (x's created by a call to int_encode). For example, -# there are two plus functions: -# -# plus Called with integer arguments and returns an integer -# int_plus Called with encoded arguments and returns an encoded result -# -# plus will be slower than int_plus because its arguments and result -# have to be translated between the x's format and integers. If doing -# a complex calculation use the int_* forms with a single encoding of -# inputs and single decoding of the output. For simple calculations -# the direct forms can be used. - -# Helper function used to wrap an int_* function into a function that -# takes a pair of integers, perhaps a function and returns an integer -# result -__gmsl_int_wrap = $(call int_decode,$(call $1,$(call int_encode,$2),$(call int_encode,$3))) -__gmsl_int_wrap1 = $(call int_decode,$(call $1,$(call int_encode,$2))) -__gmsl_int_wrap2 = $(call $1,$(call int_encode,$2),$(call int_encode,$3)) - -# ---------------------------------------------------------------------------- -# Function: int_plus -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the sum of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_plus = $(strip $(__gmsl_tr2)$1 $2) - -# ---------------------------------------------------------------------------- -# Function: plus (wrapped version of int_plus) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the sum of the two integers -# ---------------------------------------------------------------------------- -plus = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_plus,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_subtract -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the difference of the two numbers in x's representation, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -int_subtract = $(strip $(__gmsl_tr2)$(if $(call int_gte,$1,$2), \ - $(filter-out xx,$(join $1,$2)), \ - $(call __gmsl_warning,Subtraction underflow))) - -# ---------------------------------------------------------------------------- -# Function: subtract (wrapped version of int_subtract) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the difference of the two integers, -# or outputs an error on a numeric underflow -# ---------------------------------------------------------------------------- -subtract = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_subtract,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_multiply -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the product of the two numbers in x's representation -# ---------------------------------------------------------------------------- -int_multiply = $(strip $(__gmsl_tr2)$(foreach a,$1,$2)) - -# ---------------------------------------------------------------------------- -# Function: multiply (wrapped version of int_multiply) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the product of the two integers -# ---------------------------------------------------------------------------- -multiply = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_multiply,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_divide -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the result of integer division of argument 1 divided -# by argument 2 in x's representation -# ---------------------------------------------------------------------------- -int_divide = $(__gmsl_tr2)$(strip $(if $1,$(if $2, \ - $(if $(call int_gte,$1,$2), \ - x $(call int_divide,$(call int_subtract,$1,$2),$2),), \ - $(call __gmsl_error,Division by zero)))) - -# ---------------------------------------------------------------------------- -# Function: divide (wrapped version of int_divide) -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the integer division of the first argument by the second -# ---------------------------------------------------------------------------- -divide = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_divide,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_max, int_min -# Arguments: 1: A number in x's representation -# 2: Another number in x's represntation -# Returns: Returns the maximum or minimum of its arguments in x's -# representation -# ---------------------------------------------------------------------------- -int_max = $(__gmsl_tr2)$(subst xx,x,$(join $1,$2)) -int_min = $(__gmsl_tr2)$(subst xx,x,$(filter xx,$(join $1,$2))) - -# ---------------------------------------------------------------------------- -# Function: max, min -# Arguments: 1: An integer -# 2: Another integer -# Returns: Returns the maximum or minimum of its integer arguments -# ---------------------------------------------------------------------------- -max = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_max,$1,$2) -min = $(__gmsl_tr2)$(call __gmsl_int_wrap,int_min,$1,$2) - -# ---------------------------------------------------------------------------- -# Function: int_gt, int_gte, int_lt, int_lte, int_eq, int_ne -# Arguments: Two x's representation numbers to be compared -# Returns: $(true) or $(false) -# -# int_gt First argument greater than second argument -# int_gte First argument greater than or equal to second argument -# int_lt First argument less than second argument -# int_lte First argument less than or equal to second argument -# int_eq First argument is numerically equal to the second argument -# int_ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -int_gt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $2), \ - $(words $(call int_max,$1,$2)))) -int_gte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_gt,$1,$2)$(call int_eq,$1,$2)) -int_lt = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1), \ - $(words $(call int_max,$1,$2)))) -int_lte = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(call int_lt,$1,$2)$(call int_eq,$1,$2)) -int_eq = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter $(words $1),$(words $2))) -int_ne = $(__gmsl_tr2)$(call __gmsl_make_bool, \ - $(filter-out $(words $1),$(words $2))) - -# ---------------------------------------------------------------------------- -# Function: gt, gte, lt, lte, eq, ne -# Arguments: Two integers to be compared -# Returns: $(true) or $(false) -# -# gt First argument greater than second argument -# gte First argument greater than or equal to second argument -# lt First argument less than second argument -# lte First argument less than or equal to second argument -# eq First argument is numerically equal to the second argument -# ne First argument is not numerically equal to the second argument -# ---------------------------------------------------------------------------- -gt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gt,$1,$2) -gte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_gte,$1,$2) -lt = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lt,$1,$2) -lte = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_lte,$1,$2) -eq = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_eq,$1,$2) -ne = $(__gmsl_tr2)$(call __gmsl_int_wrap2,int_ne,$1,$2) - -# increment adds 1 to its argument, decrement subtracts 1. Note that -# decrement does not range check and hence will not underflow, but -# will incorrectly say that 0 - 1 = 0 - -# ---------------------------------------------------------------------------- -# Function: int_inc -# Arguments: 1: A number in x's representation -# Returns: The number incremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_inc = $(strip $(__gmsl_tr1)$1 x) - -# ---------------------------------------------------------------------------- -# Function: inc -# Arguments: 1: An integer -# Returns: The argument incremented by 1 -# ---------------------------------------------------------------------------- -inc = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_inc,$1) - -# ---------------------------------------------------------------------------- -# Function: int_dec -# Arguments: 1: A number in x's representation -# Returns: The number decremented by 1 in x's representation -# ---------------------------------------------------------------------------- -int_dec = $(__gmsl_tr1)$(strip \ - $(if $(call sne,0,$(words $1)), \ - $(wordlist 2,$(words $1),$1))) - -# ---------------------------------------------------------------------------- -# Function: dec -# Arguments: 1: An integer -# Returns: The argument decremented by 1 -# ---------------------------------------------------------------------------- -dec = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_dec,$1) - -# double doubles its argument, and halve halves it - -# ---------------------------------------------------------------------------- -# Function: int_double -# Arguments: 1: A number in x's representation -# Returns: The number doubled (i.e. * 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_double = $(strip $(__gmsl_tr1)$1 $1) - -# ---------------------------------------------------------------------------- -# Function: double -# Arguments: 1: An integer -# Returns: The integer times 2 -# ---------------------------------------------------------------------------- -double = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_double,$1) - -# ---------------------------------------------------------------------------- -# Function: int_halve -# Arguments: 1: A number in x's representation -# Returns: The number halved (i.e. / 2) and returned in x's representation -# ---------------------------------------------------------------------------- -int_halve = $(__gmsl_tr1)$(strip $(subst xx,x,$(filter-out xy x y, \ - $(join $1,$(foreach a,$1,y x))))) - -# ---------------------------------------------------------------------------- -# Function: halve -# Arguments: 1: An integer -# Returns: The integer divided by 2 -# ---------------------------------------------------------------------------- -halve = $(__gmsl_tr1)$(call __gmsl_int_wrap1,int_halve,$1) - -# ---------------------------------------------------------------------------- -# Function: sequence -# Arguments: 1: An integer -# 2: An integer -# Returns: The sequence [arg1, arg2] of integers if arg1 < arg2 or -# [arg2, arg1] if arg2 > arg1. If arg1 == arg1 return [arg1] -# ---------------------------------------------------------------------------- -sequence = $(__gmsl_tr2)$(strip $(if $(call lte,$1,$2), \ - $(call __gmsl_sequence_up,$1,$2), \ - $(call __gmsl_sequence_dn,$2,$1))) - -__gmsl_sequence_up = $(if $(call seq,$1,$2),$1,$1 $(call __gmsl_sequence_up,$(call inc,$1),$2)) -__gmsl_sequence_dn = $(if $(call seq,$1,$2),$1,$2 $(call __gmsl_sequence_dn,$1,$(call dec,$2))) - -# ---------------------------------------------------------------------------- -# Function: dec2hex, dec2bin, dec2oct -# Arguments: 1: An integer -# Returns: The decimal argument converted to hexadecimal, binary or -# octal -# ---------------------------------------------------------------------------- - -__gmsl_digit = $(subst 15,f,$(subst 14,e,$(subst 13,d,$(subst 12,c,$(subst 11,b,$(subst 10,a,$1)))))) - -dec2hex = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,16)) -dec2bin = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,2)) -dec2oct = $(call __gmsl_dec2base,$(call int_encode,$1),$(call int_encode,8)) - -__gmsl_base_divide = $(subst $2,X ,$1) -__gmsl_q = $(strip $(filter X,$1)) -__gmsl_r = $(words $(filter x,$1)) - -__gmsl_dec2base = $(eval __gmsl_temp := $(call __gmsl_base_divide,$1,$2))$(call __gmsl_dec2base_,$(call __gmsl_q,$(__gmsl_temp)),$(call __gmsl_r,$(__gmsl_temp)),$2) -__gmsl_dec2base_ = $(if $1,$(call __gmsl_dec2base,$(subst X,x,$1),$3))$(call __gmsl_digit,$2) - -ifdef __gmsl_have_eval -# ########################################################################### -# ASSOCIATIVE ARRAYS -# ########################################################################### - -# Magic string that is very unlikely to appear in a key or value - -__gmsl_aa_magic := faf192c8efbc25c27992c5bc5add390393d583c6 - -# ---------------------------------------------------------------------------- -# Function: set -# Arguments: 1: Name of associative array -# 2: The key value to associate -# 3: The value associated with the key -# Returns: Nothing -# ---------------------------------------------------------------------------- -set = $(__gmsl_tr3)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2$3)$(eval __gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1 := $3) - -# Only used internally by memoize function - -__gmsl_set = $(call set,$1,$2,$3)$3 - -# ---------------------------------------------------------------------------- -# Function: get -# Arguments: 1: Name of associative array -# 2: The key to retrieve -# Returns: The value stored in the array for that key -# ---------------------------------------------------------------------------- -get = $(strip $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(__gmsl_aa_$1_$(__gmsl_aa_magic)_$2_gmsl_aa_$1)) - -# ---------------------------------------------------------------------------- -# Function: keys -# Arguments: 1: Name of associative array -# Returns: Returns a list of all defined keys in the array -# ---------------------------------------------------------------------------- -keys = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(sort $(patsubst __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,%, \ - $(filter __gmsl_aa_$1_$(__gmsl_aa_magic)_%_gmsl_aa_$1,$(.VARIABLES)))) - -# ---------------------------------------------------------------------------- -# Function: defined -# Arguments: 1: Name of associative array -# 2: The key to test -# Returns: Returns true if the key is defined (i.e. not empty) -# ---------------------------------------------------------------------------- -defined = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(call sne,$(call get,$1,$2),) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# NAMED STACKS -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: push -# Arguments: 1: Name of stack -# 2: Value to push onto the top of the stack (must not contain -# a space) -# Returns: None -# ---------------------------------------------------------------------------- -push = $(__gmsl_tr2)$(call assert_no_space,$0,$1$2)$(call assert_no_dollar,$0,$1$2)$(eval __gmsl_stack_$1 := $2 $(if $(filter-out undefined,\ - $(origin __gmsl_stack_$1)),$(__gmsl_stack_$1))) - -# ---------------------------------------------------------------------------- -# Function: pop -# Arguments: 1: Name of stack -# Returns: Top element from the stack after removing it -# ---------------------------------------------------------------------------- -pop = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(strip $(if $(filter-out undefined,$(origin __gmsl_stack_$1)), \ - $(call first,$(__gmsl_stack_$1)) \ - $(eval __gmsl_stack_$1 := $(call rest,$(__gmsl_stack_$1))))) - -# ---------------------------------------------------------------------------- -# Function: peek -# Arguments: 1: Name of stack -# Returns: Top element from the stack without removing it -# ---------------------------------------------------------------------------- -peek = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(call first,$(__gmsl_stack_$1)) - -# ---------------------------------------------------------------------------- -# Function: depth -# Arguments: 1: Name of stack -# Returns: Number of items on the stack -# ---------------------------------------------------------------------------- -depth = $(__gmsl_tr1)$(call assert_no_space,$0,$1)$(call assert_no_dollar,$0,$1)$(words $(__gmsl_stack_$1)) - -endif # __gmsl_have_eval - -ifdef __gmsl_have_eval -# ########################################################################### -# STRING CACHE -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Function: memoize -# Arguments: 1. Name of the function to be called if the string -# has not been previously seen -# 2. A string -# Returns: Returns the result of a memo function (which the user must -# define) on the passed in string and remembers the result. -# -# Example: Set memo = $(shell echo "$1" | md5sum) to make a cache -# of MD5 hashes of strings. $(call memoize,memo,foo bar baz) -# ---------------------------------------------------------------------------- -__gmsl_memoize = $(subst $(__gmsl_space),§,$1)cc2af1bb7c4482f2ba75e338b963d3e7$(subst $(__gmsl_space),§,$2) -memoize = $(__gmsl_tr2)$(strip $(if $(call defined,__gmsl_m,$(__gmsl_memoize)),\ - $(call get,__gmsl_m,$(__gmsl_memoize)), \ - $(call __gmsl_set,__gmsl_m,$(__gmsl_memoize),$(call $1,$2)))) - -endif # __gmsl_have_eval - -# ########################################################################### -# DEBUGGING FACILITIES -# ########################################################################### - -# ---------------------------------------------------------------------------- -# Target: gmsl-print-% -# Arguments: The % should be replaced by the name of a variable that you -# wish to print out. -# Action: Echos the name of the variable that matches the % and its value. -# For example, 'make gmsl-print-SHELL' will output the value of -# the SHELL variable -# ---------------------------------------------------------------------------- -gmsl-print-%: ; @echo $* = $($*) - -# ---------------------------------------------------------------------------- -# Function: assert -# Arguments: 1: A boolean that must be true or the assertion will fail -# 2: The message to print with the assertion -# Returns: None -# ---------------------------------------------------------------------------- -assert = $(if $2,$(if $1,,$(call __gmsl_error,Assertion failure: $2))) - -# ---------------------------------------------------------------------------- -# Function: assert_exists -# Arguments: 1: Name of file that must exist, if it is missing an assertion -# will be generated -# Returns: None -# ---------------------------------------------------------------------------- -assert_exists = $(if $0,$(call assert,$(wildcard $1),file '$1' missing)) - -# ---------------------------------------------------------------------------- -# Function: assert_no_dollar -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -assert_no_dollar = $(call __gmsl_tr2)$(call assert,$(call not,$(findstring $(__gmsl_dollar),$2)),$1 called with a dollar sign in argument) - -# ---------------------------------------------------------------------------- -# Function: assert_no_space -# Arguments: 1: Name of a function being executd -# 2: Arguments to check -# Returns: None -# ---------------------------------------------------------------------------- -ifeq ($(__gmsl_spaced_vars),$(false)) -assert_no_space = $(call assert,$(call not,$(findstring $(__gmsl_aa_magic),$(subst $(__gmsl_space),$(__gmsl_aa_magic),$2))),$1 called with a space in argument) -else -assert_no_space = -endif diff --git a/roles/grafana/.manala/make/gmsl/gmsl b/roles/grafana/.manala/make/gmsl/gmsl deleted file mode 100644 index 17891f134..000000000 --- a/roles/grafana/.manala/make/gmsl/gmsl +++ /dev/null @@ -1,85 +0,0 @@ -# ---------------------------------------------------------------------------- -# -# GNU Make Standard Library (GMSL) -# -# A library of functions to be used with GNU Make's $(call) that -# provides functionality not available in standard GNU Make. -# -# Copyright (c) 2005-2014 John Graham-Cumming -# -# This file is part of GMSL -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# Neither the name of the John Graham-Cumming nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ---------------------------------------------------------------------------- - -# Determine if the library has already been included and if so don't -# bother including it again - -ifndef __gmsl_included - -# Standard definitions for true and false. true is any non-empty -# string, false is an empty string. These are intended for use with -# $(if). - -true := T -false := - -# ---------------------------------------------------------------------------- -# Function: not -# Arguments: 1: A boolean value -# Returns: Returns the opposite of the arg. (true -> false, false -> true) -# ---------------------------------------------------------------------------- -not = $(if $1,$(false),$(true)) - -# Prevent reinclusion of the library - -__gmsl_included := $(true) - -# Try to determine where this file is located. If the caller did -# include /foo/gmsl then extract the /foo/ so that __gmsl gets -# included transparently - -__gmsl_root := - -ifneq ($(MAKEFILE_LIST),) -__gmsl_root := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) - -# If there are any spaces in the path in __gmsl_root then give up - -ifeq (1,$(words $(__gmsl_root))) -__gmsl_root := $(patsubst %gmsl,%,$(__gmsl_root)) -endif - -endif - -include $(__gmsl_root)__gmsl - -endif # __gmsl_included - diff --git a/roles/grafana/.travis.yml b/roles/grafana/.travis.yml deleted file mode 100644 index 3a2430ac1..000000000 --- a/roles/grafana/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: generic - -branches: - only: - - master - -services: - - docker - -script: - - gem install chandler -v 0.9.0 - - chandler push `perl -lne '/^## \[(?!Unreleased)([\w.-]+)\] - [\w-]+$/ && print $1;' CHANGELOG.md | head -1` - -notifications: - webhooks: - urls: - - https://galaxy.ansible.com/api/v1/notifications/ diff --git a/roles/grafana/CHANGELOG.md b/roles/grafana/CHANGELOG.md deleted file mode 100644 index 076688ced..000000000 --- a/roles/grafana/CHANGELOG.md +++ /dev/null @@ -1,65 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). - -## [Unreleased] - -## [2.0.2] - 2020-08-28 -### Changed -- Explicit file permissions - -## [2.0.1] - 2020-02-13 -### Added -- Tags for each tasks, with the format `manala_rolename.taskname` - -## [2.0.0] - 2019-11-21 -### Removed -- Debian wheezy support - -## [1.0.6] - 2019-10-29 -### Fixed -- Cleanup version comparisons - -## [1.0.5] - 2019-10-24 -### Added -- Debian buster support -- Config template for 6.2 - -### Fixed -- Config snapshots handling -- Missing version 2.0 config template handling - -## [1.0.4] - 2018-11-16 -### Fixed -- Keep legacy sysvinit services handling in ansible 2.6+ - -## [1.0.3] - 2018-10-17 -### Fixed -- Python 3 compatibility - -## [1.0.2] - 2018-06-05 -### Added -- Handle dependency packages to install -- Loop over api calls until its ready - -### Changed -- Fix missings ansible 2.1 deprecation "Supplying headers via HEADER_* is deprecated" -- Replace deprecated jinja tests used as filters -- Replace deprecated uses of "include" -- Pass apt module packages list directly to the `name` option - -## [1.0.1] - 2017-12-06 -### Added -- Debian stretch support - -### Changed -- Fix ansible 2.1 deprecation "Supplying headers via HEADER_* is deprecated" - -## [1.0.0] - 2016-01-27 -### Added -- Install grafana -- Add grafana v2.0, v2.1, v2.5, v3.1, v4.0, v4.1 config templates -- Configure grafana datasources -- Configure grafana dashboards diff --git a/roles/grafana/Makefile b/roles/grafana/Makefile deleted file mode 100644 index 5c07b57a3..000000000 --- a/roles/grafana/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -.SILENT: - -########## -# Manala # -########## - -include .manala/make/Makefile - -######## -# Role # -######## - -ROLE = manala.grafana -ROLE_DISTRIBUTIONS = debian.jessie debian.stretch debian.buster diff --git a/roles/grafana/README.md b/roles/grafana/README.md index 44f1bc934..b4c7b55aa 100644 --- a/roles/grafana/README.md +++ b/roles/grafana/README.md @@ -1,24 +1,12 @@ -####################################################################################################### - -# :exclamation: DEPRECATION :exclamation: - -## This repository and the role associated are deprecated in favor of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles) - -## You will find informations on its usage on the [collection repository](https://github.com/manala/ansible-roles) - -####################################################################################################### - -# Ansible Role: Grafana [![Build Status](https://travis-ci.org/manala/ansible-role-grafana.svg?branch=master)](https://travis-ci.org/manala/ansible-role-grafana) - -:exclamation: [Report issues](https://github.com/manala/ansible-roles/issues) and [send Pull Requests](https://github.com/manala/ansible-roles/pulls) in the [main Ansible Role repository](https://github.com/manala/ansible-roles) :exclamation: +# Ansible Role: Grafana This role will deal with the configuration of [Grafana](http://grafana.org/). -It's part of the [Manala Ansible stack](http://www.manala.io) but can be used as a stand alone component. +It's part of the [Manala Ansible Collection](https://galaxy.ansible.com/manala/roles). ## Requirements -This role is made to work with the __grafana__ official debian packages, available on the [__grafana__ debian repository](http://docs.grafana.org/installation/debian/#apt-repository). Please use the [**manala.apt**](https://galaxy.ansible.com/manala/apt/) role to handle it properly. +This role is made to work with the __grafana__ official debian packages, available on the [__grafana__ debian repository](http://docs.grafana.org/installation/debian/#apt-repository). Please use the [**manala.roles.apt**](../apt/) role to handle it properly. ```yaml manala_apt_preferences: @@ -31,56 +19,24 @@ None. ## Installation -### Ansible 2+ - -Using ansible galaxy cli: - -```bash -ansible-galaxy install manala.grafana -``` - -Using ansible galaxy requirements file: - -```yaml -- src: manala.grafana -``` - -## Role Handlers - -| Name | Type | Description | -| ----------------- | ------- | ---------------------- | -| `grafana restart` | Service | Restart grafana server | +Installation instructions can be found in the main [README.md](https://github.com/manala/ansible-roles/blob/master/README.md) ## Role Variables -| Name | Default | Type | Description | -| ----------------------------------------- | -------------------------- | ------- | -------------------------------------- | -| `manala_grafana_version` | ~ | String | Installed version | -| `manala_grafana_install_packages` | ~ | Array | Dependency packages to install | -| `manala_grafana_install_packages_default` | ['grafana'] | Array | Default dependency packages to install | -| `manala_grafana_config_file` | '/etc/grafana/grafana.ini' | String | Configuration file path | -| `manala_grafana_config_template` | 'config/default.j2' | String | Configuration base template path | -| `manala_grafana_config` | [] | Array | Configuration directives | -| `manala_grafana_api_url` | 'http://127.0.0.1:3000' | String | API endpoint | -| `manala_grafana_api_user` | 'admin' | String | API user | -| `manala_grafana_api_password` | 'admin' | String | API password | -| `manala_grafana_datasources_exclusive` | false | Boolean | Remove old datasources | -| `manala_grafana_datasources` | [] | Array | Datasources | -| `manala_grafana_dashboards_exclusive` | false | Boolean | Remove old dashboards | -| `manala_grafana_dashboards` | [] | Array | Dashboards | +You can find all variables and default values used by this role in the [defaults/main.yml](./defaults/main.yml) file ### Configuration example See : http://docs.grafana.org/installation/configuration/ ```yaml -manala_grafana_config: - - app_mode: production - - server: - - http_port: 3001 - - security: - - admin_user: admin - - admin_password: admin +manala_grafana_config: | + app_mode = production + [server] + http_port = 3001 + [security] + admin_user = admin + admin_password = admin manala_grafana_api_url: http://127.0.0.1:3000 manala_grafana_api_user: admin @@ -88,24 +44,24 @@ manala_grafana_api_password: admin manala_grafana_datasources_exclusive: true manala_grafana_datasources: - - name: telegraf - type: influxdb + - name: telegraf + type: influxdb isDefault: true - access: proxy + access: proxy basicAuth: false - url: http://localhost:8086 - database: telegraf - username: '' - password: '' + url: http://localhost:8086 + database: telegraf + username: "" + password: "" manala_grafana_dashboards_exclusive: true manala_grafana_dashboards: - template: grafana/dashboards/system.json inputs: - - name: "DS_TELEGRAF" - pluginId: "influxdb" - type: "datasource" - value: "telegraf" + - name: DS_TELEGRAF + pluginId: influxdb + type: datasource + value: telegraf overwrite: true ``` @@ -113,13 +69,16 @@ manala_grafana_dashboards: ```yaml - hosts: grafana - roles: - - { role: manala.grafana } + tasks: + - import_role: + name: manala.roles.grafana ``` -# Licence +# Licencing + +This collection is distributed under the MIT license. -MIT +See [LICENSE](https://opensource.org/licenses/MIT) to see the full text. # Author information diff --git a/roles/grafana/defaults/main.yml b/roles/grafana/defaults/main.yml index 80a5bd160..9890cf3b7 100644 --- a/roles/grafana/defaults/main.yml +++ b/roles/grafana/defaults/main.yml @@ -1,9 +1,10 @@ --- -# Grafana installed version. Used to determine base template. +# Available values: '~' (autodetect), 3.1, '4.0', 4.1, 6.2, ... manala_grafana_version: ~ # Install +# Note: First package name in list is used for version autodetection manala_grafana_install_packages: ~ manala_grafana_install_packages_default: - grafana @@ -11,7 +12,7 @@ manala_grafana_install_packages_default: # Config manala_grafana_config_file: /etc/grafana/grafana.ini manala_grafana_config_template: ~ -manala_grafana_config: [] +manala_grafana_config: ~ # Api parameters manala_grafana_api_url: http://127.0.0.1:3000 diff --git a/roles/grafana/handlers/main.yml b/roles/grafana/handlers/main.yml index 96ef00ee8..207a63b52 100644 --- a/roles/grafana/handlers/main.yml +++ b/roles/grafana/handlers/main.yml @@ -2,5 +2,7 @@ - name: grafana restart service: - name: grafana-server + name: "{{ item }}" state: restarted + loop: + - grafana-server diff --git a/roles/grafana/meta/main.yml b/roles/grafana/meta/main.yml index 65837d129..8c737af1f 100644 --- a/roles/grafana/meta/main.yml +++ b/roles/grafana/meta/main.yml @@ -4,19 +4,19 @@ dependencies: [] galaxy_info: - role_name: grafana - author: Manala - company: Manala - description: Handle grafana - license: MIT - min_ansible_version: 2.5.0 - issue_tracker_url: https://github.com/manala/ansible-roles/issues + role_name: grafana + author: Manala + company: Manala + description: Handle grafana + license: MIT + min_ansible_version: 2.9.0 + issue_tracker_url: https://github.com/manala/ansible-roles/issues platforms: - name: Debian versions: - - jessie - stretch - buster + - bullseye galaxy_tags: - monitoring - grafana diff --git a/roles/grafana/tasks/config.yml b/roles/grafana/tasks/config.yml index 24d3d38d8..3f89416e5 100644 --- a/roles/grafana/tasks/config.yml +++ b/roles/grafana/tasks/config.yml @@ -2,10 +2,11 @@ - name: config > Template template: - src: "{{ manala_grafana_config_template|ternary(manala_grafana_config_template, 'config/default.j2') }}" + src: "{{ manala_grafana_config_template|ternary(manala_grafana_config_template, 'config/_default.j2') }}" dest: "{{ manala_grafana_config_file }}" owner: root group: root mode: "0644" - notify: - - grafana restart + when: manala_grafana_config_template + or manala_grafana_config + register: __manala_grafana_config_template_result diff --git a/roles/grafana/tasks/dashboards.yml b/roles/grafana/tasks/dashboards.yml index c73a6ec71..700a14f87 100644 --- a/roles/grafana/tasks/dashboards.yml +++ b/roles/grafana/tasks/dashboards.yml @@ -2,7 +2,7 @@ # Import dashboards - name: dashboards > List dashboards - register: _manala_grafana_dashboards_list_output + register: __manala_grafana_dashboards_list_output uri: url: "{{ manala_grafana_api_url }}/api/search" method: GET @@ -13,14 +13,14 @@ headers: Content-Type: application/json when: manala_grafana_dashboards_exclusive - until: _manala_grafana_dashboards_list_output is not failed + until: __manala_grafana_dashboards_list_output is not failed retries: 12 delay: 1 # Delete dashboards - name: dashboards > Delete dashboards - register: _manala_grafana_dashboards_delete_output - failed_when: "'Dashboard not found' in _manala_grafana_dashboards_delete_output|to_json" + register: __manala_grafana_dashboards_delete_output + failed_when: "'Dashboard not found' in __manala_grafana_dashboards_delete_output|to_json" uri: url: "{{ manala_grafana_api_url }}/api/dashboards/{{ item.uri }}" method: DELETE @@ -30,12 +30,12 @@ status_code: 200 headers: Content-Type: application/json - with_items: "{{ _manala_grafana_dashboards_list_output.json|default([]) }}" + loop: "{{ __manala_grafana_dashboards_list_output.json|default([]) }}" when: manala_grafana_dashboards_exclusive # Import dashboards - name: dashboards > Import dashboards - register: _manala_grafana_dashboards_import_output + register: __manala_grafana_dashboards_import_output uri: url: "{{ manala_grafana_api_url }}/api/dashboards/import" method: POST @@ -52,7 +52,7 @@ status_code: 200 headers: Content-Type: application/json - with_items: "{{ manala_grafana_dashboards }}" - until: _manala_grafana_dashboards_import_output is not failed + loop: "{{ manala_grafana_dashboards }}" + until: __manala_grafana_dashboards_import_output is not failed retries: 12 delay: 1 diff --git a/roles/grafana/tasks/datasources.yml b/roles/grafana/tasks/datasources.yml index 1b0549137..4a1cd065a 100644 --- a/roles/grafana/tasks/datasources.yml +++ b/roles/grafana/tasks/datasources.yml @@ -8,15 +8,15 @@ user: "{{ manala_grafana_api_user }}" password: "{{ manala_grafana_api_password }}" return_content: true - register: _manala_grafana_datasources_output - until: _manala_grafana_datasources_output is not failed + register: __manala_grafana_datasources_output + until: __manala_grafana_datasources_output is not failed retries: 12 delay: 1 # Update existing datasources - name: datasources > Update datasources - register: _manala_grafana_datasources_update_output - failed_when: "'Datasource updated' not in _manala_grafana_datasources_update_output|to_json" + register: __manala_grafana_datasources_update_output + failed_when: "'Datasource updated' not in __manala_grafana_datasources_update_output|to_json" uri: url: "{{ manala_grafana_api_url }}/api/datasources/{{ item[0].id }}" method: PUT @@ -27,15 +27,17 @@ status_code: 200 headers: Content-Type: application/json - with_nested: - - "{{ _manala_grafana_datasources_output.json|default([]) }}" - - "{{ manala_grafana_datasources }}" + loop: "{{ + __manala_grafana_datasources_output.json|default([]) + | product(manala_grafana_datasources) + | list + }}" when: item[0].name == item[1].name # Create non existing datasources - name: datasources > Create datasources - register: _manala_grafana_datasources_create_output - failed_when: "'Datasource added' not in _manala_grafana_datasources_create_output|to_json" + register: __manala_grafana_datasources_create_output + failed_when: "'Datasource added' not in __manala_grafana_datasources_create_output|to_json" uri: url: "{{ manala_grafana_api_url }}/api/datasources" method: POST @@ -46,13 +48,13 @@ status_code: 200 headers: Content-Type: application/json - with_items: "{{ manala_grafana_datasources }}" - when: item.name not in _manala_grafana_datasources_output.json|map(attribute='name')|list + loop: "{{ manala_grafana_datasources }}" + when: item.name not in __manala_grafana_datasources_output.json|map(attribute='name')|list # Delete non added datasources - name: datasources > Delete datasources - register: _manala_grafana_datasources_delete_output - failed_when: "'Data source deleted' not in _manala_grafana_datasources_delete_output.json.message" + register: __manala_grafana_datasources_delete_output + failed_when: "'Data source deleted' not in __manala_grafana_datasources_delete_output.json.message" uri: url: "{{ manala_grafana_api_url }}/api/datasources/{{ item.id }}" method: DELETE @@ -62,5 +64,7 @@ status_code: 200 headers: Content-Type: application/json - with_items: "{{ _manala_grafana_datasources_output.json|default([]) }}" - when: manala_grafana_datasources_exclusive and item.name not in manala_grafana_datasources|map(attribute='name')|list + loop: "{{ __manala_grafana_datasources_output.json|default([]) }}" + when: + - manala_grafana_datasources_exclusive + - item.name not in manala_grafana_datasources|map(attribute='name')|list diff --git a/roles/grafana/tasks/install.yml b/roles/grafana/tasks/install.yml index 78b011179..7aea211ac 100644 --- a/roles/grafana/tasks/install.yml +++ b/roles/grafana/tasks/install.yml @@ -2,7 +2,27 @@ - name: install > Packages apt: - name: "{{ manala_grafana_install_packages|default(manala_grafana_install_packages_default, True) }}" + name: "{{ item }}" install_recommends: false - update_cache: true - cache_valid_time: 3600 + update_cache: true + cache_valid_time: 3600 + loop: + - "{{ manala_grafana_install_packages|default(manala_grafana_install_packages_default, True) }}" + +- block: + - name: install > Parse version + command: > + dpkg -s + {{ manala_grafana_install_packages|default(manala_grafana_install_packages_default, True) | first }} + register: __manala_grafana_version + changed_when: false + - name: install > Set version + set_fact: + manala_grafana_version: "{{ + __manala_grafana_version.stdout + | regex_search('Version: (\\d+:)?(?P\\d+\\.\\d+)', '\\g') + | first + }}" + changed_when: false + when: manala_grafana_version is none + check_mode: false diff --git a/roles/grafana/tasks/main.yml b/roles/grafana/tasks/main.yml index 9219e8acb..27b4b8a1f 100644 --- a/roles/grafana/tasks/main.yml +++ b/roles/grafana/tasks/main.yml @@ -21,14 +21,16 @@ # Datasources - import_tasks: datasources.yml - when: manala_grafana_datasources|length or manala_grafana_datasources_exclusive + when: manala_grafana_datasources|length + or manala_grafana_datasources_exclusive tags: - manala_grafana - manala_grafana.datasources # Dashboards - import_tasks: dashboards.yml - when: manala_grafana_dashboards|length or manala_grafana_dashboards_exclusive + when: manala_grafana_dashboards|length + or manala_grafana_dashboards_exclusive tags: - manala_grafana - manala_grafana.dashboards diff --git a/roles/grafana/tasks/services.yml b/roles/grafana/tasks/services.yml index 4921d1d29..52231e646 100644 --- a/roles/grafana/tasks/services.yml +++ b/roles/grafana/tasks/services.yml @@ -2,11 +2,14 @@ - name: services > Services service: - name: "{{ item }}" - state: started + name: "{{ item }}" + state: "{{ + 'restarted' + if ( + __manala_grafana_config_template_result|default({}) is changed + ) else + 'started' + }}" enabled: true - # Keep legacy sysvinit services handling in ansible 2.6+ - # See: https://github.com/ansible/ansible/pull/48724 - use: "{{ (ansible_service_mgr == 'sysvinit')|ternary('service', omit) }}" - with_items: + loop: - grafana-server diff --git a/roles/grafana/templates/config/2.0/default.j2 b/roles/grafana/templates/config/2.0/default.j2 deleted file mode 100644 index fc78057a0..000000000 --- a/roles/grafana/templates/config/2.0/default.j2 +++ /dev/null @@ -1,273 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_grafana_config -%} - -{% set config_paths = [] -%} -{% set config_server = [] -%} -{% set config_database = [] -%} -{% set config_session = [] -%} -{% set config_analytics = [] -%} -{% set config_security = [] -%} -{% set config_users = [] -%} -{% set config_auth_anonymous = [] -%} -{% set config_auth_github = [] -%} -{% set config_auth_google = [] -%} -{% set config_log = [] -%} -{% set config_log_console = [] -%} -{% set config_log_file = [] -%} -{% set config_event_publisher = [] -%} - -{%- for configs in config -%} - {%- for config_name, config_parameters in configs.items() -%} - {%- if config_name == 'paths' -%} - {%- if config_paths.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'server' -%} - {%- if config_server.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'database' -%} - {%- if config_database.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'session' -%} - {%- if config_session.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'analytics' -%} - {%- if config_analytics.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'security' -%} - {%- if config_security.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'users' -%} - {%- if config_users.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.anonymous' -%} - {%- if config_auth_anonymous.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.github' -%} - {%- if config_auth_github.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.google' -%} - {%- if config_auth_google.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log' -%} - {%- if config_log.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.console' -%} - {%- if config_log_console.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.file' -%} - {%- if config_log_file.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'event_publisher' -%} - {%- if config_event_publisher.extend(config_parameters) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} -{%- endfor -%} - - -##################### Grafana Configuration Example ##################### -# -# Everything has defaults so you only need to uncomment things you want to -# change - -{{ macros.config_row(config, 'app_mode', '; app_mode = production', 0, true) }} - -#################################### Paths #################################### -[paths] -# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is useD) -# -{{ macros.config_row(config_paths, 'data', ';data = /var/lib/grafana', 0, true) }} - -# -# Directory where grafana can store logs -# -{{ macros.config_row(config_paths, 'logs', ';logs = /var/log/grafana', 0, true) }} - -#################################### Server #################################### -[server] -# Protocol (http or https) -{{ macros.config_row(config_server, 'protocol', ';protocol = http', 0, true) }} - -# The ip address to bind to, empty will bind to all interfaces -{{ macros.config_row(config_server, 'http_addr', ';http_addr = ', 0, true) }} - -# The http port to use -{{ macros.config_row(config_server, 'http_port', ';http_port = 3000', 0, true) }} - -# The public facing domain name used to access grafana from a browser -{{ macros.config_row(config_server, 'domain', ';domain = localhost', 0, true) }} - -# The full public facing url -{{ macros.config_row(config_server, 'root_url', ';root_url = %(protocol)s://%(domain)s:%(http_port)s/', 0, true) }} - -# Log web requests -{{ macros.config_row(config_server, 'router_logging', ';router_logging = false', 0, true) }} - -# the path relative working path -{{ macros.config_row(config_server, 'static_root_path', ';static_root_path = public', 0, true) }} - -# enable gzip -{{ macros.config_row(config_server, 'enable_gzip', ';enable_gzip = false', 0, true) }} - -# https certs & key file -{{ macros.config_row(config_server, 'cert_file', ';cert_file = ', 0, true) }} -{{ macros.config_row(config_server, 'cert_key', ';cert_key = ', 0, true) }} - -#################################### Database #################################### -[database] -# Either "mysql", "postgres" or "sqlite3", it's your choice -{{ macros.config_row(config_database, 'type', ';type = sqlite3', 0, true) }} -{{ macros.config_row(config_database, 'host', ';host = 127.0.0.1:3306', 0, true) }} -{{ macros.config_row(config_database, 'name', ';name = grafana', 0, true) }} -{{ macros.config_row(config_database, 'user', ';user = root', 0, true) }} -{{ macros.config_row(config_database, 'password', ';password = ', 0, true) }} - -# For "postgres" only, either "disable", "require" or "verify-full" -{{ macros.config_row(config_database, 'ssl_mode', ';ssl_mode = disable', 0, true) }} - -# For "sqlite3" only, path relative to data_path setting -{{ macros.config_row(config_database, 'path', ';path = grafana.db', 0, true) }} - -#################################### Session #################################### -[session] -# Either "memory", "file", "redis", "mysql", default is "memory" -{{ macros.config_row(config_session, 'provider', ';provider = file', 0, true) }} - -# Provider config options -# memory: not have any config yet -# file: session dir path, is relative to grafana data_path -# redis: config like redis server addr, poolSize, password, e.g. `127.0.0.1:6379,100,grafana` -# mysql: go-sql-driver/mysql dsn config string, e.g. `user:password@tcp(127.0.0.1)/database_name` -{{ macros.config_row(config_session, 'provider_config', ';provider_config = sessions', 0, true) }} - -# Session cookie name -{{ macros.config_row(config_session, 'cookie_name', ';cookie_name = grafana_sess', 0, true) }} - -# If you use session in https only, default is false -{{ macros.config_row(config_session, 'cookie_secure', ';cookie_secure = false', 0, true) }} - -# Session life time, default is 86400 -{{ macros.config_row(config_session, 'cookie_life_time', ';session_life_time = 86400', 0, true) }} - -#################################### Analytics #################################### -[analytics] -# Server reporting, sends usage counters to stats.grafana.org every 24 hours. -# No ip addresses are being tracked, only simple counters to track -# running instances, dashboard and error counts. It is very helpful to us. -# Change this option to false to disable reporting. -{{ macros.config_row(config_analytics, 'reporting_enabled', ';reporting_enabled = true', 0, true) }} - -# Google Analytics universal tracking code, only enabled if you specify an id here -{{ macros.config_row(config_analytics, 'google_analytics_ua_id', ';google_analytics_ua_id =', 0, true) }} - -#################################### Security #################################### -[security] -# default admin user, created on startup -{{ macros.config_row(config_security, 'admin_user', ';admin_user = admin', 0, true) }} - -# default admin password, can be changed before first start of grafana, or in profile settings -{{ macros.config_row(config_security, 'admin_password', ';admin_password = admin', 0, true) }} - -# used for signing -{{ macros.config_row(config_security, 'secret_key', ';secret_key = SW2YcwTIb9zpOOhoPsM', 0, true) }} - -# Auto-login remember days -{{ macros.config_row(config_security, 'login_remember_days', ';login_remember_days = 7', 0, true) }} -{{ macros.config_row(config_security, 'cookie_username', ';cookie_username = grafana_user', 0, true) }} -{{ macros.config_row(config_security, 'cookie_remember_name', ';cookie_remember_name = grafana_remember', 0, true) }} - -#################################### Users #################################### -[users] -# disable user signup / registration -{{ macros.config_row(config_users, 'allow_sign_up', ';allow_sign_up = true', 0, true) }} - -# Allow non admin users to create organizations -{{ macros.config_row(config_users, 'allow_org_create', ';allow_org_create = true', 0, true) }} - -# Set to true to automatically assign new users to the default organization (id 1) -{{ macros.config_row(config_users, 'auto_assign_org', ';auto_assign_org = true', 0, true) }} - -# Default role new users will be automatically assigned (if disabled above is set to true) -{{ macros.config_row(config_users, 'auto_assign_org_role', ';auto_assign_org_role = Viewer', 0, true) }} - -#################################### Anonymous Auth ########################## -[auth.anonymous] -# enable anonymous access -{{ macros.config_row(config_auth_anonymous, 'enabled', ';enabled = false', 0, true) }} - -# specify organization name that should be used for unauthenticated users -{{ macros.config_row(config_auth_anonymous, 'org_name', ';org_name = Main Org.', 0, true) }} - -# specify role for unauthenticated users -{{ macros.config_row(config_auth_anonymous, 'org_role', ';org_role = Viewer', 0, true) }} - -#################################### Github Auth ########################## -[auth.github] -{{ macros.config_row(config_auth_github, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_github, 'client_id', ';client_id = some_id', 0, true) }} -{{ macros.config_row(config_auth_github, 'client_secret', ';client_secret = some_secret', 0, true) }} -{{ macros.config_row(config_auth_github, 'scopes', ';scopes = user:email', 0, true) }} -{{ macros.config_row(config_auth_github, 'auth_url', ';auth_url = https://github.com/login/oauth/authorize', 0, true) }} -{{ macros.config_row(config_auth_github, 'token_url', ';token_url = https://github.com/login/oauth/access_token', 0, true) }} -{{ macros.config_row(config_auth_github, 'api_url', ';api_url = https://api.github.com/user', 0, true) }} -# Uncomment bellow to only allow specific email domains -{{ macros.config_row(config_auth_github, 'allowed_domains', '; allowed_domains = mycompany.com othercompany.com', 0, true) }} - -#################################### Google Auth ########################## -[auth.google] -{{ macros.config_row(config_auth_google, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_google, 'client_id', ';client_id = some_client_id', 0, true) }} -{{ macros.config_row(config_auth_google, 'client_secret', ';client_secret = some_client_secret', 0, true) }} -{{ macros.config_row(config_auth_google, 'scopes', ';scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email', 0, true) }} -{{ macros.config_row(config_auth_google, 'auth_url', ';auth_url = https://accounts.google.com/o/oauth2/auth', 0, true) }} -{{ macros.config_row(config_auth_google, 'token_url', ';token_url = https://accounts.google.com/o/oauth2/token', 0, true) }} -{{ macros.config_row(config_auth_google, 'api_url', ';api_url = https://www.googleapis.com/oauth2/v1/userinfo', 0, true) }} -# Uncomment bellow to only allow specific email domains -{{ macros.config_row(config_auth_google, 'allowed_domains', '; allowed_domains = mycompany.com othercompany.com', 0, true) }} -{{ macros.config_row(config_auth_google, 'allow_sign_up', ';allow_sign_up = false', 0, true) }} - -#################################### Logging ########################## -[log] -# Either "console", "file", default is "console" -# Use comma to separate multiple modes, e.g. "console, file" -{{ macros.config_row(config_log, 'mode', ';mode = console, file', 0, true) }} - -# Buffer length of channel, keep it as it is if you don't know what it is. -{{ macros.config_row(config_log, 'buffer_len', ';buffer_len = 10000', 0, true) }} - -# Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace" -{{ macros.config_row(config_log, 'level', ';level = Info', 0, true) }} - -# For "console" mode only -[log.console] -{{ macros.config_row(config_log_console, 'level', ';level =', 0, true) }} - -# For "file" mode only -[log.file] -{{ macros.config_row(config_log_file, 'level', ';level =', 0, true) }} -# This enables automated log rotate(switch of following options), default is true -{{ macros.config_row(config_log_file, 'log_rotate', ';log_rotate = true', 0, true) }} - -# Max line number of single file, default is 1000000 -{{ macros.config_row(config_log_file, 'max_lines', ';max_lines = 1000000', 0, true) }} - -# Max size shift of single file, default is 28 means 1 << 28, 256MB -{{ macros.config_row(config_log_file, 'max_lines_shift', ';max_lines_shift = 28', 0, true) }} - -# Segment log daily, default is true -{{ macros.config_row(config_log_file, 'daily_rotate', ';daily_rotate = true', 0, true) }} - -# Expired days of log file(delete after max days), default is 7 -{{ macros.config_row(config_log_file, 'max_days', ';max_days = 7', 0, true) }} - -#################################### AMPQ Event Publisher ########################## -[event_publisher] -{{ macros.config_row(config_event_publisher, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_event_publisher, 'rabbitmq_url', ';rabbitmq_url = amqp://localhost/', 0, true) }} -{{ macros.config_row(config_event_publisher, 'exchange', ';exchange = grafana_events', 0, true) }} - - -{{ macros.config(config, [ - 'app_mode', - 'paths', - 'server', - 'database', - 'session', - 'analytics', - 'security', - 'users', - 'auth.anonymous', - 'auth.github', - 'auth.google', - 'log', - 'log.console', - 'log.file', - 'event_publisher' -]) }} diff --git a/roles/grafana/templates/config/2.1/default.j2 b/roles/grafana/templates/config/2.1/default.j2 deleted file mode 100644 index 66f786a3a..000000000 --- a/roles/grafana/templates/config/2.1/default.j2 +++ /dev/null @@ -1,318 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_grafana_config -%} - -{% set config_paths = [] -%} -{% set config_server = [] -%} -{% set config_database = [] -%} -{% set config_session = [] -%} -{% set config_analytics = [] -%} -{% set config_security = [] -%} -{% set config_users = [] -%} -{% set config_auth_anonymous = [] -%} -{% set config_auth_github = [] -%} -{% set config_auth_google = [] -%} -{% set config_auth_proxy = [] -%} -{% set config_auth_basic = [] -%} -{% set config_auth_ldap = [] -%} -{% set config_smtp = [] -%} -{% set config_emails = [] -%} -{% set config_log = [] -%} -{% set config_log_console = [] -%} -{% set config_log_file = [] -%} -{% set config_event_publisher = [] -%} -{% set config_dashboards_json = [] -%} - -{%- for configs in config -%} - {%- for config_name, config_parameters in configs.items() -%} - {%- if config_name == 'paths' -%} - {%- if config_paths.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'server' -%} - {%- if config_server.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'database' -%} - {%- if config_database.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'session' -%} - {%- if config_session.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'analytics' -%} - {%- if config_analytics.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'security' -%} - {%- if config_security.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'users' -%} - {%- if config_users.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.anonymous' -%} - {%- if config_auth_anonymous.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.google' -%} - {%- if config_auth_google.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.github' -%} - {%- if config_auth_github.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.proxy' -%} - {%- if config_auth_proxy.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.basic' -%} - {%- if config_auth_basic.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.ldap' -%} - {%- if config_auth_ldap.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'smtp' -%} - {%- if config_smtp.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'emails' -%} - {%- if config_emails.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log' -%} - {%- if config_log.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.console' -%} - {%- if config_log_console.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.file' -%} - {%- if config_log_file.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'event_publisher' -%} - {%- if config_event_publisher.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'dashboards.json' -%} - {%- if config_dashboards_json.extend(config_parameters) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} -{%- endfor -%} - - -##################### Grafana Configuration Example ##################### -# -# Everything has defaults so you only need to uncomment things you want to -# change - -{{ macros.config_row(config, 'app_mode', '; app_mode = production', 0, true) }} - -#################################### Paths #################################### -[paths] -# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used) -# -{{ macros.config_row(config_paths, 'data', ';data = /var/lib/grafana', 0, true) }} -# -# Directory where grafana can store logs -# -{{ macros.config_row(config_paths, 'logs', ';logs = /var/log/grafana', 0, true) }} - -#################################### Server #################################### -[server] -# Protocol (http or https) -{{ macros.config_row(config_server, 'protocol', ';protocol = http', 0, true) }} - -# The ip address to bind to, empty will bind to all interfaces -{{ macros.config_row(config_server, 'http_addr', ';http_addr =', 0, true) }} - -# The http port to use -{{ macros.config_row(config_server, 'http_port', ';http_port = 3000', 0, true) }} - -# The public facing domain name used to access grafana from a browser -{{ macros.config_row(config_server, 'domain', ';domain = localhost', 0, true) }} - -# Redirect to correct domain if host header does not match domain -# Prevents DNS rebinding attacks -{{ macros.config_row(config_server, 'enforce_domain', ';enforce_domain = false', 0, true) }} - -# The full public facing url -{{ macros.config_row(config_server, 'root_url', ';root_url = %(protocol)s://%(domain)s:%(http_port)s/', 0, true) }} - -# Log web requests -{{ macros.config_row(config_server, 'router_logging', ';router_logging = false', 0, true) }} - -# the path relative working path -{{ macros.config_row(config_server, 'static_root_path', ';static_root_path = public', 0, true) }} - -# enable gzip -{{ macros.config_row(config_server, 'enable_gzip', ';enable_gzip = false', 0, true) }} - -# https certs & key file -{{ macros.config_row(config_server, 'cert_file', ';cert_file =', 0, true) }} -{{ macros.config_row(config_server, 'cert_key', ';cert_key =', 0, true) }} - -#################################### Database #################################### -[database] -# Either "mysql", "postgres" or "sqlite3", it's your choice -{{ macros.config_row(config_database, 'type', ';type = sqlite3', 0, true) }} -{{ macros.config_row(config_database, 'host', ';host = 127.0.0.1:3306', 0, true) }} -{{ macros.config_row(config_database, 'name', ';name = grafana', 0, true) }} -{{ macros.config_row(config_database, 'user', ';user = root', 0, true) }} -{{ macros.config_row(config_database, 'password', ';password =', 0, true) }} - -# For "postgres" only, either "disable", "require" or "verify-full" -{{ macros.config_row(config_database, 'ssl_mode', ';ssl_mode = disable', 0, true) }} - -# For "sqlite3" only, path relative to data_path setting -{{ macros.config_row(config_database, 'path', ';path = grafana.db', 0, true) }} - -#################################### Session #################################### -[session] -# Either "memory", "file", "redis", "mysql", "postgresql", default is "file" -{{ macros.config_row(config_session, 'provider', ';provider = file', 0, true) }} - -# Provider config options -# memory: not have any config yet -# file: session dir path, is relative to grafana data_path -# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=grafana` -# mysql: go-sql-driver/mysql dsn config string, e.g. `user:password@tcp(127.0.0.1:3306)/database_name` -# postgres: user=a password=b host=localhost port=5432 dbname=c sslmode=disable -{{ macros.config_row(config_session, 'provider_config', ';provider_config = sessions', 0, true) }} - -# Session cookie name -{{ macros.config_row(config_session, 'cookie_name', ';cookie_name = grafana_sess', 0, true) }} - -# If you use session in https only, default is false -{{ macros.config_row(config_session, 'cookie_secure', ';cookie_secure = false', 0, true) }} - -# Session life time, default is 86400 -{{ macros.config_row(config_session, 'cookie_life_time', ';session_life_time = 86400', 0, true) }} - -#################################### Analytics #################################### -[analytics] -# Server reporting, sends usage counters to stats.grafana.org every 24 hours. -# No ip addresses are being tracked, only simple counters to track -# running instances, dashboard and error counts. It is very helpful to us. -# Change this option to false to disable reporting. -{{ macros.config_row(config_analytics, 'reporting_enabled', ';reporting_enabled = true', 0, true) }} - -# Google Analytics universal tracking code, only enabled if you specify an id here -{{ macros.config_row(config_analytics, 'google_analytics_ua_id', ';google_analytics_ua_id =', 0, true) }} - -#################################### Security #################################### -[security] -# default admin user, created on startup -{{ macros.config_row(config_security, 'admin_user', ';admin_user = admin', 0, true) }} - -# default admin password, can be changed before first start of grafana, or in profile settings -{{ macros.config_row(config_security, 'admin_password', ';admin_password = admin', 0, true) }} - -# used for signing -{{ macros.config_row(config_security, 'secret_key', ';secret_key = SW2YcwTIb9zpOOhoPsMm', 0, true) }} - -# Auto-login remember days -{{ macros.config_row(config_security, 'login_remember_days', ';login_remember_days = 7', 0, true) }} -{{ macros.config_row(config_security, 'cookie_username', ';cookie_username = grafana_user', 0, true) }} -{{ macros.config_row(config_security, 'cookie_remember_name', ';cookie_remember_name = grafana_remember', 0, true) }} - -# disable gravatar profile images -{{ macros.config_row(config_security, 'disable_gravatar', ';disable_gravatar = false', 0, true) }} - -#################################### Users #################################### -[users] -# disable user signup / registration -{{ macros.config_row(config_users, 'allow_sign_up', ';allow_sign_up = true', 0, true) }} - -# Allow non admin users to create organizations -{{ macros.config_row(config_users, 'allow_org_create', ';allow_org_create = true', 0, true) }} - -# Set to true to automatically assign new users to the default organization (id 1) -{{ macros.config_row(config_users, 'auto_assign_org', ';auto_assign_org = true', 0, true) }} - -# Default role new users will be automatically assigned (if disabled above is set to true) -{{ macros.config_row(config_users, 'auto_assign_org_role', ';auto_assign_org_role = Viewer', 0, true) }} - -#################################### Anonymous Auth ########################## -[auth.anonymous] -# enable anonymous access -{{ macros.config_row(config_auth_anonymous, 'enabled', ';enabled = false', 0, true) }} - -# specify organization name that should be used for unauthenticated users -{{ macros.config_row(config_auth_anonymous, 'org_name', ';org_name = Main Org.', 0, true) }} - -# specify role for unauthenticated users -{{ macros.config_row(config_auth_anonymous, 'org_role', ';org_role = Viewer', 0, true) }} - -#################################### Github Auth ########################## -[auth.github] -{{ macros.config_row(config_auth_github, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_github, 'allow_sign_up', ';allow_sign_up = false', 0, true) }} -{{ macros.config_row(config_auth_github, 'client_id', ';client_id = some_id', 0, true) }} -{{ macros.config_row(config_auth_github, 'client_secret', ';client_secret = some_secret', 0, true) }} -{{ macros.config_row(config_auth_github, 'scopes', ';scopes = user:email,read:org', 0, true) }} -{{ macros.config_row(config_auth_github, 'auth_url', ';auth_url = https://github.com/login/oauth/authorize', 0, true) }} -{{ macros.config_row(config_auth_github, 'token_url', ';token_url = https://github.com/login/oauth/access_token', 0, true) }} -{{ macros.config_row(config_auth_github, 'api_url', ';api_url = https://api.github.com/user', 0, true) }} -{{ macros.config_row(config_auth_github, 'team_ids', ';team_ids =', 0, true) }} -{{ macros.config_row(config_auth_github, 'allowed_domains', ';allowed_domains =', 0, true) }} -{{ macros.config_row(config_auth_github, 'allowed_organizations', ';allowed_organizations =', 0, true) }} - -#################################### Google Auth ########################## -[auth.google] -{{ macros.config_row(config_auth_google, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_google, 'allow_sign_up', ';allow_sign_up = false', 0, true) }} -{{ macros.config_row(config_auth_google, 'client_id', ';client_id = some_client_id', 0, true) }} -{{ macros.config_row(config_auth_google, 'client_secret', ';client_secret = some_client_secret', 0, true) }} -{{ macros.config_row(config_auth_google, 'scopes', ';scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email', 0, true) }} -{{ macros.config_row(config_auth_google, 'auth_url', ';auth_url = https://accounts.google.com/o/oauth2/auth', 0, true) }} -{{ macros.config_row(config_auth_google, 'token_url', ';token_url = https://accounts.google.com/o/oauth2/token', 0, true) }} -{{ macros.config_row(config_auth_google, 'api_url', ';api_url = https://www.googleapis.com/oauth2/v1/userinfo', 0, true) }} -{{ macros.config_row(config_auth_google, 'allowed_domains', '; allowed_domains =', 0, true) }} - -#################################### Auth Proxy ########################## -[auth.proxy] -{{ macros.config_row(config_auth_proxy, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'header_name', ';header_name = X-WEBAUTH-USER', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'header_property', ';header_property = username', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'auto_sign_up', ';auto_sign_up = true', 0, true) }} - -#################################### Basic Auth ########################## -[auth.basic] -{{ macros.config_row(config_auth_basic, 'enabled', ';enabled = true', 0, true) }} - -#################################### Auth LDAP ########################## -[auth.ldap] -{{ macros.config_row(config_auth_ldap, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_ldap, 'config_file', ';config_file = /etc/grafana/ldap.toml', 0, true) }} - -#################################### SMTP / Emailing ########################## -[smtp] -{{ macros.config_row(config_smtp, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_smtp, 'host', ';host = localhost:25', 0, true) }} -{{ macros.config_row(config_smtp, 'user', ';user =', 0, true) }} -{{ macros.config_row(config_smtp, 'password', ';password =', 0, true) }} -{{ macros.config_row(config_smtp, 'cert_file', ';cert_file =', 0, true) }} -{{ macros.config_row(config_smtp, 'key_file', ';key_file =', 0, true) }} -{{ macros.config_row(config_smtp, 'skip_verify', ';skip_verify = false', 0, true) }} -{{ macros.config_row(config_smtp, 'from_address', ';from_address = admin@grafana.localhost', 0, true) }} - -[emails] -{{ macros.config_row(config_emails, 'welcome_email_on_sign_up', ';welcome_email_on_sign_up = false', 0, true) }} - -#################################### Logging ########################## -[log] -# Either "console", "file", default is "console" -# Use comma to separate multiple modes, e.g. "console, file" -{{ macros.config_row(config_log, 'mode', ';mode = console, file', 0, true) }} - -# Buffer length of channel, keep it as it is if you don't know what it is. -{{ macros.config_row(config_log, 'buffer_len', ';buffer_len = 10000', 0, true) }} - -# Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace" -{{ macros.config_row(config_log, 'level', ';level = Info', 0, true) }} - -# For "console" mode only -[log.console] -{{ macros.config_row(config_log_console, 'level', ';level =', 0, true) }} - -# For "file" mode only -[log.file] -{{ macros.config_row(config_log_file, 'level', ';level =', 0, true) }} -# This enables automated log rotate(switch of following options), default is true -{{ macros.config_row(config_log_file, 'log_rotate', ';log_rotate = true', 0, true) }} - -# Max line number of single file, default is 1000000 -{{ macros.config_row(config_log_file, 'max_lines', ';max_lines = 1000000', 0, true) }} - -# Max size shift of single file, default is 28 means 1 << 28, 256MB -{{ macros.config_row(config_log_file, 'max_lines_shift', ';max_lines_shift = 28', 0, true) }} - -# Segment log daily, default is true -{{ macros.config_row(config_log_file, 'daily_rotate', ';daily_rotate = true', 0, true) }} - -# Expired days of log file(delete after max days), default is 7 -{{ macros.config_row(config_log_file, 'max_days', ';max_days = 7', 0, true) }} - -#################################### AMPQ Event Publisher ########################## -[event_publisher] -{{ macros.config_row(config_event_publisher, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_event_publisher, 'rabbitmq_url', ';rabbitmq_url = amqp://localhost/', 0, true) }} -{{ macros.config_row(config_event_publisher, 'exchange', ';exchange = grafana_events', 0, true) }} - -;#################################### Dashboard JSON files ########################## -[dashboards.json] -{{ macros.config_row(config_dashboards_json, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_dashboards_json, 'path', ';path = /var/lib/grafana/dashboards', 0, true) }} - - - diff --git a/roles/grafana/templates/config/2.5/default.j2 b/roles/grafana/templates/config/2.5/default.j2 deleted file mode 100644 index 79fecdc3f..000000000 --- a/roles/grafana/templates/config/2.5/default.j2 +++ /dev/null @@ -1,321 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_grafana_config -%} - -{% set config_paths = [] -%} -{% set config_server = [] -%} -{% set config_database = [] -%} -{% set config_session = [] -%} -{% set config_analytics = [] -%} -{% set config_security = [] -%} -{% set config_users = [] -%} -{% set config_auth_anonymous = [] -%} -{% set config_auth_github = [] -%} -{% set config_auth_google = [] -%} -{% set config_auth_proxy = [] -%} -{% set config_auth_basic = [] -%} -{% set config_auth_ldap = [] -%} -{% set config_smtp = [] -%} -{% set config_emails = [] -%} -{% set config_log = [] -%} -{% set config_log_console = [] -%} -{% set config_log_file = [] -%} -{% set config_event_publisher = [] -%} -{% set config_dashboards_json = [] -%} - -{%- for configs in config -%} - {%- for config_name, config_parameters in configs.items() -%} - {%- if config_name == 'paths' -%} - {%- if config_paths.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'server' -%} - {%- if config_server.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'database' -%} - {%- if config_database.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'session' -%} - {%- if config_session.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'analytics' -%} - {%- if config_analytics.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'security' -%} - {%- if config_security.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'users' -%} - {%- if config_users.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.anonymous' -%} - {%- if config_auth_anonymous.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.google' -%} - {%- if config_auth_google.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.github' -%} - {%- if config_auth_github.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.proxy' -%} - {%- if config_auth_proxy.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.basic' -%} - {%- if config_auth_basic.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.ldap' -%} - {%- if config_auth_ldap.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'smtp' -%} - {%- if config_smtp.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'emails' -%} - {%- if config_emails.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log' -%} - {%- if config_log.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.console' -%} - {%- if config_log_console.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.file' -%} - {%- if config_log_file.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'event_publisher' -%} - {%- if config_event_publisher.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'dashboards.json' -%} - {%- if config_dashboards_json.extend(config_parameters) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} -{%- endfor -%} - - -##################### Grafana Configuration Example ##################### -# -# Everything has defaults so you only need to uncomment things you want to -# change - -# possible values : production, development -{{ macros.config_row(config, 'app_mode', '; app_mode = production', 0, true) }} - -#################################### Paths #################################### -[paths] -# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used) -# -{{ macros.config_row(config_paths, 'data', ';data = /var/lib/grafana', 0, true) }} -# -# Directory where grafana can store logs -# -{{ macros.config_row(config_paths, 'logs', ';logs = /var/log/grafana', 0, true) }} - -#################################### Server #################################### -[server] -# Protocol (http or https) -{{ macros.config_row(config_server, 'protocol', ';protocol = http', 0, true) }} - -# The ip address to bind to, empty will bind to all interfaces -{{ macros.config_row(config_server, 'http_addr', ';http_addr =', 0, true) }} - -# The http port to use -{{ macros.config_row(config_server, 'http_port', ';http_port = 3000', 0, true) }} - -# The public facing domain name used to access grafana from a browser -{{ macros.config_row(config_server, 'domain', ';domain = localhost', 0, true) }} - -# Redirect to correct domain if host header does not match domain -# Prevents DNS rebinding attacks -{{ macros.config_row(config_server, 'enforce_domain', ';enforce_domain = false', 0, true) }} - -# The full public facing url -{{ macros.config_row(config_server, 'root_url', ';root_url = %(protocol)s://%(domain)s:%(http_port)s/', 0, true) }} - -# Log web requests -{{ macros.config_row(config_server, 'router_logging', ';router_logging = false', 0, true) }} - -# the path relative working path -{{ macros.config_row(config_server, 'static_root_path', ';static_root_path = public', 0, true) }} - -# enable gzip -{{ macros.config_row(config_server, 'enable_gzip', ';enable_gzip = false', 0, true) }} - -# https certs & key file -{{ macros.config_row(config_server, 'cert_file', ';cert_file =', 0, true) }} -{{ macros.config_row(config_server, 'cert_key', ';cert_key =', 0, true) }} - -#################################### Database #################################### -[database] -# Either "mysql", "postgres" or "sqlite3", it's your choice -{{ macros.config_row(config_database, 'type', ';type = sqlite3', 0, true) }} -{{ macros.config_row(config_database, 'host', ';host = 127.0.0.1:3306', 0, true) }} -{{ macros.config_row(config_database, 'name', ';name = grafana', 0, true) }} -{{ macros.config_row(config_database, 'user', ';user = root', 0, true) }} -{{ macros.config_row(config_database, 'password', ';password =', 0, true) }} - -# For "postgres" only, either "disable", "require" or "verify-full" -{{ macros.config_row(config_database, 'ssl_mode', ';ssl_mode = disable', 0, true) }} - -# For "sqlite3" only, path relative to data_path setting -{{ macros.config_row(config_database, 'path', ';path = grafana.db', 0, true) }} - -#################################### Session #################################### -[session] -# Either "memory", "file", "redis", "mysql", "postgres", default is "file" -{{ macros.config_row(config_session, 'provider', ';provider = file', 0, true) }} - -# Provider config options -# memory: not have any config yet -# file: session dir path, is relative to grafana data_path -# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=grafana` -# mysql: go-sql-driver/mysql dsn config string, e.g. `user:password@tcp(127.0.0.1:3306)/database_name` -# postgres: user=a password=b host=localhost port=5432 dbname=c sslmode=disable -{{ macros.config_row(config_session, 'provider_config', ';provider_config = sessions', 0, true) }} - -# Session cookie name -{{ macros.config_row(config_session, 'cookie_name', ';cookie_name = grafana_sess', 0, true) }} - -# If you use session in https only, default is false -{{ macros.config_row(config_session, 'cookie_secure', ';cookie_secure = false', 0, true) }} - -# Session life time, default is 86400 -{{ macros.config_row(config_session, 'cookie_life_time', ';session_life_time = 86400', 0, true) }} - -#################################### Analytics #################################### -[analytics] -# Server reporting, sends usage counters to stats.grafana.org every 24 hours. -# No ip addresses are being tracked, only simple counters to track -# running instances, dashboard and error counts. It is very helpful to us. -# Change this option to false to disable reporting. -{{ macros.config_row(config_analytics, 'reporting_enabled', ';reporting_enabled = true', 0, true) }} - -# Google Analytics universal tracking code, only enabled if you specify an id here -{{ macros.config_row(config_analytics, 'google_analytics_ua_id', ';google_analytics_ua_id =', 0, true) }} - -#################################### Security #################################### -[security] -# default admin user, created on startup -{{ macros.config_row(config_security, 'admin_user', ';admin_user = admin', 0, true) }} - -# default admin password, can be changed before first start of grafana, or in profile settings -{{ macros.config_row(config_security, 'admin_password', ';admin_password = admin', 0, true) }} - -# used for signing -{{ macros.config_row(config_security, 'secret_key', ';secret_key = SW2YcwTIb9zpOOhoPsMm', 0, true) }} - -# Auto-login remember days -{{ macros.config_row(config_security, 'login_remember_days', ';login_remember_days = 7', 0, true) }} -{{ macros.config_row(config_security, 'cookie_username', ';cookie_username = grafana_user', 0, true) }} -{{ macros.config_row(config_security, 'cookie_remember_name', ';cookie_remember_name = grafana_remember', 0, true) }} - -# disable gravatar profile images -{{ macros.config_row(config_security, 'disable_gravatar', ';disable_gravatar = false', 0, true) }} - -# data source proxy whitelist (ip_or_domain:port seperated by spaces) -{{ macros.config_row(config_security, 'data_source_proxy_whitelist', ';data_source_proxy_whitelist =', 0, true) }} - -#################################### Users #################################### -[users] -# disable user signup / registration -{{ macros.config_row(config_users, 'allow_sign_up', ';allow_sign_up = true', 0, true) }} - -# Allow non admin users to create organizations -{{ macros.config_row(config_users, 'allow_org_create', ';allow_org_create = true', 0, true) }} - -# Set to true to automatically assign new users to the default organization (id 1) -{{ macros.config_row(config_users, 'auto_assign_org', ';auto_assign_org = true', 0, true) }} - -# Default role new users will be automatically assigned (if disabled above is set to true) -{{ macros.config_row(config_users, 'auto_assign_org_role', ';auto_assign_org_role = Viewer', 0, true) }} - -#################################### Anonymous Auth ########################## -[auth.anonymous] -# enable anonymous access -{{ macros.config_row(config_auth_anonymous, 'enabled', ';enabled = false', 0, true) }} - -# specify organization name that should be used for unauthenticated users -{{ macros.config_row(config_auth_anonymous, 'org_name', ';org_name = Main Org.', 0, true) }} - -# specify role for unauthenticated users -{{ macros.config_row(config_auth_anonymous, 'org_role', ';org_role = Viewer', 0, true) }} - -#################################### Github Auth ########################## -[auth.github] -{{ macros.config_row(config_auth_github, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_github, 'allow_sign_up', ';allow_sign_up = false', 0, true) }} -{{ macros.config_row(config_auth_github, 'client_id', ';client_id = some_id', 0, true) }} -{{ macros.config_row(config_auth_github, 'client_secret', ';client_secret = some_secret', 0, true) }} -{{ macros.config_row(config_auth_github, 'scopes', ';scopes = user:email,read:org', 0, true) }} -{{ macros.config_row(config_auth_github, 'auth_url', ';auth_url = https://github.com/login/oauth/authorize', 0, true) }} -{{ macros.config_row(config_auth_github, 'token_url', ';token_url = https://github.com/login/oauth/access_token', 0, true) }} -{{ macros.config_row(config_auth_github, 'api_url', ';api_url = https://api.github.com/user', 0, true) }} -{{ macros.config_row(config_auth_github, 'team_ids', ';team_ids =', 0, true) }} -{{ macros.config_row(config_auth_github, 'allowed_organizations', ';allowed_organizations =', 0, true) }} - -#################################### Google Auth ########################## -[auth.google] -{{ macros.config_row(config_auth_google, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_google, 'allow_sign_up', ';allow_sign_up = false', 0, true) }} -{{ macros.config_row(config_auth_google, 'client_id', ';client_id = some_client_id', 0, true) }} -{{ macros.config_row(config_auth_google, 'client_secret', ';client_secret = some_client_secret', 0, true) }} -{{ macros.config_row(config_auth_google, 'scopes', ';scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email', 0, true) }} -{{ macros.config_row(config_auth_google, 'auth_url', ';auth_url = https://accounts.google.com/o/oauth2/auth', 0, true) }} -{{ macros.config_row(config_auth_google, 'token_url', ';token_url = https://accounts.google.com/o/oauth2/token', 0, true) }} -{{ macros.config_row(config_auth_google, 'api_url', ';api_url = https://www.googleapis.com/oauth2/v1/userinfo', 0, true) }} -{{ macros.config_row(config_auth_google, 'allowed_domains', '; allowed_domains =', 0, true) }} - -#################################### Auth Proxy ########################## -[auth.proxy] -{{ macros.config_row(config_auth_proxy, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'header_name', ';header_name = X-WEBAUTH-USER', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'header_property', ';header_property = username', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'auto_sign_up', ';auto_sign_up = true', 0, true) }} - -#################################### Basic Auth ########################## -[auth.basic] -{{ macros.config_row(config_auth_basic, 'enabled', ';enabled = true', 0, true) }} - -#################################### Auth LDAP ########################## -[auth.ldap] -{{ macros.config_row(config_auth_ldap, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_ldap, 'config_file', ';config_file = /etc/grafana/ldap.toml', 0, true) }} - -#################################### SMTP / Emailing ########################## -[smtp] -{{ macros.config_row(config_smtp, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_smtp, 'host', ';host = localhost:25', 0, true) }} -{{ macros.config_row(config_smtp, 'user', ';user =', 0, true) }} -{{ macros.config_row(config_smtp, 'password', ';password =', 0, true) }} -{{ macros.config_row(config_smtp, 'cert_file', ';cert_file =', 0, true) }} -{{ macros.config_row(config_smtp, 'key_file', ';key_file =', 0, true) }} -{{ macros.config_row(config_smtp, 'skip_verify', ';skip_verify = false', 0, true) }} -{{ macros.config_row(config_smtp, 'from_address', ';from_address = admin@grafana.localhost', 0, true) }} - -[emails] -{{ macros.config_row(config_emails, 'welcome_email_on_sign_up', ';welcome_email_on_sign_up = false', 0, true) }} - -#################################### Logging ########################## -[log] -# Either "console", "file", default is "console" -# Use comma to separate multiple modes, e.g. "console, file" -{{ macros.config_row(config_log, 'mode', ';mode = console, file', 0, true) }} - -# Buffer length of channel, keep it as it is if you don't know what it is. -{{ macros.config_row(config_log, 'buffer_len', ';buffer_len = 10000', 0, true) }} - -# Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace" -{{ macros.config_row(config_log, 'level', ';level = Info', 0, true) }} - -# For "console" mode only -[log.console] -{{ macros.config_row(config_log_console, 'level', ';level =', 0, true) }} - -# For "file" mode only -[log.file] -{{ macros.config_row(config_log_file, 'level', ';level =', 0, true) }} -# This enables automated log rotate(switch of following options), default is true -{{ macros.config_row(config_log_file, 'log_rotate', ';log_rotate = true', 0, true) }} - -# Max line number of single file, default is 1000000 -{{ macros.config_row(config_log_file, 'max_lines', ';max_lines = 1000000', 0, true) }} - -# Max size shift of single file, default is 28 means 1 << 28, 256MB -{{ macros.config_row(config_log_file, 'max_lines_shift', ';max_lines_shift = 28', 0, true) }} - -# Segment log daily, default is true -{{ macros.config_row(config_log_file, 'daily_rotate', ';daily_rotate = true', 0, true) }} - -# Expired days of log file(delete after max days), default is 7 -{{ macros.config_row(config_log_file, 'max_days', ';max_days = 7', 0, true) }} - -#################################### AMPQ Event Publisher ########################## -[event_publisher] -{{ macros.config_row(config_event_publisher, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_event_publisher, 'rabbitmq_url', ';rabbitmq_url = amqp://localhost/', 0, true) }} -{{ macros.config_row(config_event_publisher, 'exchange', ';exchange = grafana_events', 0, true) }} - -;#################################### Dashboard JSON files ########################## -[dashboards.json] -{{ macros.config_row(config_dashboards_json, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_dashboards_json, 'path', ';path = /var/lib/grafana/dashboards', 0, true) }} - - - diff --git a/roles/grafana/templates/config/3.1/default.j2 b/roles/grafana/templates/config/3.1/default.j2 deleted file mode 100644 index 4966d9dca..000000000 --- a/roles/grafana/templates/config/3.1/default.j2 +++ /dev/null @@ -1,396 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_grafana_config -%} - -{% set config_paths = [] -%} -{% set config_server = [] -%} -{% set config_database = [] -%} -{% set config_session = [] -%} -{% set config_analytics = [] -%} -{% set config_security = [] -%} -{% set config_snapshots = [] -%} -{% set config_users = [] -%} -{% set config_auth_anonymous = [] -%} -{% set config_auth_github = [] -%} -{% set config_auth_google = [] -%} -{% set config_auth_proxy = [] -%} -{% set config_auth_basic = [] -%} -{% set config_auth_ldap = [] -%} -{% set config_smtp = [] -%} -{% set config_emails = [] -%} -{% set config_log = [] -%} -{% set config_log_console = [] -%} -{% set config_log_file = [] -%} -{% set config_log_syslog = [] -%} -{% set config_event_publisher = [] -%} -{% set config_dashboards_json = [] -%} -{% set config_metrics = [] -%} -{% set config_grafana_net = [] -%} - -{%- for configs in config -%} - {%- for config_name, config_parameters in configs.items() -%} - {%- if config_name == 'paths' -%} - {%- if config_paths.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'server' -%} - {%- if config_server.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'database' -%} - {%- if config_database.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'session' -%} - {%- if config_session.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'analytics' -%} - {%- if config_analytics.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'security' -%} - {%- if config_security.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'snapshots' -%} - {%- if config_snapshots.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'users' -%} - {%- if config_users.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.anonymous' -%} - {%- if config_auth_anonymous.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.google' -%} - {%- if config_auth_google.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.github' -%} - {%- if config_auth_github.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.proxy' -%} - {%- if config_auth_proxy.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.basic' -%} - {%- if config_auth_basic.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.ldap' -%} - {%- if config_auth_ldap.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'smtp' -%} - {%- if config_smtp.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'emails' -%} - {%- if config_emails.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log' -%} - {%- if config_log.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.console' -%} - {%- if config_log_console.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.file' -%} - {%- if config_log_file.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.syslog' -%} - {%- if config_log_syslog.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'event_publisher' -%} - {%- if config_event_publisher.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'dashboards.json' -%} - {%- if config_dashboards_json.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'metrics' -%} - {%- if config_metrics.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'grafana_net' -%} - {%- if config_grafana_net.extend(config_parameters) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} -{%- endfor -%} - - -##################### Grafana Configuration Example ##################### -# -# Everything has defaults so you only need to uncomment things you want to -# change - -# possible values : production, development -{{ macros.config_row(config, 'app_mode', '; app_mode = production', 0, true) }} -# instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty -{{ macros.config_row(config, 'instance_name', '; instance_name = ${HOSTNAME}', 0, true) }} - -#################################### Paths #################################### -[paths] -# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used) -# -{{ macros.config_row(config_paths, 'data', ';data = /var/lib/grafana', 0, true) }} -# -# Directory where grafana can store logs -# -{{ macros.config_row(config_paths, 'logs', ';logs = /var/log/grafana', 0, true) }} - -#################################### Server #################################### -[server] -# Protocol (http or https) -{{ macros.config_row(config_server, 'protocol', ';protocol = http', 0, true) }} - -# The ip address to bind to, empty will bind to all interfaces -{{ macros.config_row(config_server, 'http_addr', ';http_addr =', 0, true) }} - -# The http port to use -{{ macros.config_row(config_server, 'http_port', ';http_port = 3000', 0, true) }} - -# The public facing domain name used to access grafana from a browser -{{ macros.config_row(config_server, 'domain', ';domain = localhost', 0, true) }} - -# Redirect to correct domain if host header does not match domain -# Prevents DNS rebinding attacks -{{ macros.config_row(config_server, 'enforce_domain', ';enforce_domain = false', 0, true) }} - -# The full public facing url -{{ macros.config_row(config_server, 'root_url', ';root_url = %(protocol)s://%(domain)s:%(http_port)s/', 0, true) }} - -# Log web requests -{{ macros.config_row(config_server, 'router_logging', ';router_logging = false', 0, true) }} - -# the path relative working path -{{ macros.config_row(config_server, 'static_root_path', ';static_root_path = public', 0, true) }} - -# enable gzip -{{ macros.config_row(config_server, 'enable_gzip', ';enable_gzip = false', 0, true) }} - -# https certs & key file -{{ macros.config_row(config_server, 'cert_file', ';cert_file =', 0, true) }} -{{ macros.config_row(config_server, 'cert_key', ';cert_key =', 0, true) }} - -#################################### Database #################################### -[database] -# Either "mysql", "postgres" or "sqlite3", it's your choice -{{ macros.config_row(config_database, 'type', ';type = sqlite3', 0, true) }} -{{ macros.config_row(config_database, 'host', ';host = 127.0.0.1:3306', 0, true) }} -{{ macros.config_row(config_database, 'name', ';name = grafana', 0, true) }} -{{ macros.config_row(config_database, 'user', ';user = root', 0, true) }} -{{ macros.config_row(config_database, 'password', ';password =', 0, true) }} - -# For "postgres" only, either "disable", "require" or "verify-full" -{{ macros.config_row(config_database, 'ssl_mode', ';ssl_mode = disable', 0, true) }} - -# For "sqlite3" only, path relative to data_path setting -{{ macros.config_row(config_database, 'path', ';path = grafana.db', 0, true) }} - -#################################### Session #################################### -[session] -# Either "memory", "file", "redis", "mysql", "postgres", default is "file" -{{ macros.config_row(config_session, 'provider', ';provider = file', 0, true) }} - -# Provider config options -# memory: not have any config yet -# file: session dir path, is relative to grafana data_path -# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=grafana` -# mysql: go-sql-driver/mysql dsn config string, e.g. `user:password@tcp(127.0.0.1:3306)/database_name` -# postgres: user=a password=b host=localhost port=5432 dbname=c sslmode=disable -{{ macros.config_row(config_session, 'provider_config', ';provider_config = sessions', 0, true) }} - -# Session cookie name -{{ macros.config_row(config_session, 'cookie_name', ';cookie_name = grafana_sess', 0, true) }} - -# If you use session in https only, default is false -{{ macros.config_row(config_session, 'cookie_secure', ';cookie_secure = false', 0, true) }} - -# Session life time, default is 86400 -{{ macros.config_row(config_session, 'cookie_life_time', ';session_life_time = 86400', 0, true) }} - -#################################### Analytics #################################### -[analytics] -# Server reporting, sends usage counters to stats.grafana.org every 24 hours. -# No ip addresses are being tracked, only simple counters to track -# running instances, dashboard and error counts. It is very helpful to us. -# Change this option to false to disable reporting. -{{ macros.config_row(config_analytics, 'reporting_enabled', ';reporting_enabled = true', 0, true) }} - -# Set to false to disable all checks to https://grafana.net -# for new vesions (grafana itself and plugins), check is used -# in some UI views to notify that grafana or plugin update exists -# This option does not cause any auto updates, nor send any information -# only a GET request to http://grafana.net to get latest versions -{{ macros.config_row(config_analytics, 'check_for_updates', 'check_for_updates = true', 0, true) }} - -# Google Analytics universal tracking code, only enabled if you specify an id here -{{ macros.config_row(config_analytics, 'google_analytics_ua_id', ';google_analytics_ua_id =', 0, true) }} - -#################################### Security #################################### -[security] -# default admin user, created on startup -{{ macros.config_row(config_security, 'admin_user', ';admin_user = admin', 0, true) }} - -# default admin password, can be changed before first start of grafana, or in profile settings -{{ macros.config_row(config_security, 'admin_password', ';admin_password = admin', 0, true) }} - -# used for signing -{{ macros.config_row(config_security, 'secret_key', ';secret_key = SW2YcwTIb9zpOOhoPsMm', 0, true) }} - -# Auto-login remember days -{{ macros.config_row(config_security, 'login_remember_days', ';login_remember_days = 7', 0, true) }} -{{ macros.config_row(config_security, 'cookie_username', ';cookie_username = grafana_user', 0, true) }} -{{ macros.config_row(config_security, 'cookie_remember_name', ';cookie_remember_name = grafana_remember', 0, true) }} - -# disable gravatar profile images -{{ macros.config_row(config_security, 'disable_gravatar', ';disable_gravatar = false', 0, true) }} - -# data source proxy whitelist (ip_or_domain:port separated by spaces) -{{ macros.config_row(config_security, 'data_source_proxy_whitelist', ';data_source_proxy_whitelist =', 0, true) }} - -[snapshots] -# snapshot sharing options -{{ macros.config_row(config_snapshots, 'external_enabled', ';external_enabled = true', 0, true) }} -{{ macros.config_row(config_snapshots, 'external_snapshot_url', ';external_snapshot_url = https://snapshots-origin.raintank.io', 0, true) }} -{{ macros.config_row(config_snapshots, 'external_snapshot_name', ';external_snapshot_name = Publish to snapshot.raintank.io', 0, true) }} - -#################################### Users #################################### -[users] -# disable user signup / registration -{{ macros.config_row(config_users, 'allow_sign_up', ';allow_sign_up = true', 0, true) }} - -# Allow non admin users to create organizations -{{ macros.config_row(config_users, 'allow_org_create', ';allow_org_create = true', 0, true) }} - -# Set to true to automatically assign new users to the default organization (id 1) -{{ macros.config_row(config_users, 'auto_assign_org', ';auto_assign_org = true', 0, true) }} - -# Default role new users will be automatically assigned (if disabled above is set to true) -{{ macros.config_row(config_users, 'auto_assign_org_role', ';auto_assign_org_role = Viewer', 0, true) }} - -# Background text for the user field on the login page -{{ macros.config_row(config_users, 'login_hint', ';login_hint = email or username', 0, true) }} - -# Default UI theme ("dark" or "light") -{{ macros.config_row(config_users, 'default_theme', ';default_theme', 0, true) }} - -#################################### Anonymous Auth ########################## -[auth.anonymous] -# enable anonymous access -{{ macros.config_row(config_auth_anonymous, 'enabled', ';enabled = false', 0, true) }} - -# specify organization name that should be used for unauthenticated users -{{ macros.config_row(config_auth_anonymous, 'org_name', ';org_name = Main Org.', 0, true) }} - -# specify role for unauthenticated users -{{ macros.config_row(config_auth_anonymous, 'org_role', ';org_role = Viewer', 0, true) }} - -#################################### Github Auth ########################## -[auth.github] -{{ macros.config_row(config_auth_github, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_github, 'allow_sign_up', ';allow_sign_up = false', 0, true) }} -{{ macros.config_row(config_auth_github, 'client_id', ';client_id = some_id', 0, true) }} -{{ macros.config_row(config_auth_github, 'client_secret', ';client_secret = some_secret', 0, true) }} -{{ macros.config_row(config_auth_github, 'scopes', ';scopes = user:email,read:org', 0, true) }} -{{ macros.config_row(config_auth_github, 'auth_url', ';auth_url = https://github.com/login/oauth/authorize', 0, true) }} -{{ macros.config_row(config_auth_github, 'token_url', ';token_url = https://github.com/login/oauth/access_token', 0, true) }} -{{ macros.config_row(config_auth_github, 'api_url', ';api_url = https://api.github.com/user', 0, true) }} -{{ macros.config_row(config_auth_github, 'team_ids', ';team_ids =', 0, true) }} -{{ macros.config_row(config_auth_github, 'allowed_organizations', ';allowed_organizations =', 0, true) }} - -#################################### Google Auth ########################## -[auth.google] -{{ macros.config_row(config_auth_google, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_google, 'allow_sign_up', ';allow_sign_up = false', 0, true) }} -{{ macros.config_row(config_auth_google, 'client_id', ';client_id = some_client_id', 0, true) }} -{{ macros.config_row(config_auth_google, 'client_secret', ';client_secret = some_client_secret', 0, true) }} -{{ macros.config_row(config_auth_google, 'scopes', ';scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email', 0, true) }} -{{ macros.config_row(config_auth_google, 'auth_url', ';auth_url = https://accounts.google.com/o/oauth2/auth', 0, true) }} -{{ macros.config_row(config_auth_google, 'token_url', ';token_url = https://accounts.google.com/o/oauth2/token', 0, true) }} -{{ macros.config_row(config_auth_google, 'api_url', ';api_url = https://www.googleapis.com/oauth2/v1/userinfo', 0, true) }} -{{ macros.config_row(config_auth_google, 'allowed_domains', '; allowed_domains =', 0, true) }} - -#################################### Auth Proxy ########################## -[auth.proxy] -{{ macros.config_row(config_auth_proxy, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'header_name', ';header_name = X-WEBAUTH-USER', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'header_property', ';header_property = username', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'auto_sign_up', ';auto_sign_up = true', 0, true) }} - -#################################### Basic Auth ########################## -[auth.basic] -{{ macros.config_row(config_auth_basic, 'enabled', ';enabled = true', 0, true) }} - -#################################### Auth LDAP ########################## -[auth.ldap] -{{ macros.config_row(config_auth_ldap, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_ldap, 'config_file', ';config_file = /etc/grafana/ldap.toml', 0, true) }} - -#################################### SMTP / Emailing ########################## -[smtp] -{{ macros.config_row(config_smtp, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_smtp, 'host', ';host = localhost:25', 0, true) }} -{{ macros.config_row(config_smtp, 'user', ';user =', 0, true) }} -{{ macros.config_row(config_smtp, 'password', ';password =', 0, true) }} -{{ macros.config_row(config_smtp, 'cert_file', ';cert_file =', 0, true) }} -{{ macros.config_row(config_smtp, 'key_file', ';key_file =', 0, true) }} -{{ macros.config_row(config_smtp, 'skip_verify', ';skip_verify = false', 0, true) }} -{{ macros.config_row(config_smtp, 'from_address', ';from_address = admin@grafana.localhost', 0, true) }} - -[emails] -{{ macros.config_row(config_emails, 'welcome_email_on_sign_up', ';welcome_email_on_sign_up = false', 0, true) }} - -#################################### Logging ########################## -[log] -# Either "console", "file", "syslog". Default is console and file -# Use space to separate multiple modes, e.g. "console file" -{{ macros.config_row(config_log, 'mode', ';mode = console, file', 0, true) }} - -# Buffer length of channel, keep it as it is if you don't know what it is. -{{ macros.config_row(config_log, 'buffer_len', ';buffer_len = 10000', 0, true) }} - -# Buffer length of channel, keep it as it is if you don't know what it is. -{{ macros.config_row(config_log, 'buffer_len', ';buffer_len = 10000', 0, true) }} - -# Either "trace", "debug", "info", "warn", "error", "critical", default is "info" -{{ macros.config_row(config_log, 'level', ';level = info', 0, true) }} - -# For "console" mode only -[log.console] -{{ macros.config_row(config_log_console, 'level', ';level =', 0, true) }} - -# log line format, valid options are text, console and json -{{ macros.config_row(config_log_console, 'format', ';format = console', 0, true) }} - -# For "file" mode only -[log.file] -{{ macros.config_row(config_log_file, 'level', ';level =', 0, true) }} - -# log line format, valid options are text, console and json -{{ macros.config_row(config_log_file, 'format', ';format = text', 0, true) }} - -# This enables automated log rotate(switch of following options), default is true -{{ macros.config_row(config_log_file, 'log_rotate', ';log_rotate = true', 0, true) }} - -# Max line number of single file, default is 1000000 -{{ macros.config_row(config_log_file, 'max_lines', ';max_lines = 1000000', 0, true) }} - -# Max size shift of single file, default is 28 means 1 << 28, 256MB -{{ macros.config_row(config_log_file, 'max_size_shift', ';max_size_shift = 28', 0, true) }} - -# Segment log daily, default is true -{{ macros.config_row(config_log_file, 'daily_rotate', ';daily_rotate = true', 0, true) }} - -# Expired days of log file(delete after max days), default is 7 -{{ macros.config_row(config_log_file, 'max_days', ';max_days = 7', 0, true) }} - -[log.syslog] -{{ macros.config_row(config_log_syslog, 'level', ';level =', 0, true) }} - -# log line format, valid options are text, console and json -{{ macros.config_row(config_log_syslog, 'format', ';format = text', 0, true) }} - -# Syslog network type and address. This can be udp, tcp, or unix. If left blank, the default unix ndpoints will be used. -{{ macros.config_row(config_log_syslog, 'network', ';network =', 0, true) }} -{{ macros.config_row(config_log_syslog, 'address', ';address =', 0, true) }} - -# Syslog facility. user, daemon and local0 through local7 are valid. -{{ macros.config_row(config_log_syslog, 'facility', ';facility =', 0, true) }} - -# Syslog tag. By default, the process' argv[0] is used. -{{ macros.config_row(config_log_syslog, 'tag', ';tag =', 0, true) }} - -#################################### AMPQ Event Publisher ########################## -[event_publisher] -{{ macros.config_row(config_event_publisher, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_event_publisher, 'rabbitmq_url', ';rabbitmq_url = amqp://localhost/', 0, true) }} -{{ macros.config_row(config_event_publisher, 'exchange', ';exchange = grafana_events', 0, true) }} - -;#################################### Dashboard JSON files ########################## -[dashboards.json] -{{ macros.config_row(config_dashboards_json, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_dashboards_json, 'path', ';path = /var/lib/grafana/dashboards', 0, true) }} - -#################################### Internal Grafana Metrics ########################## -# Metrics available at HTTP API Url /api/metrics -[metrics] -# Disable / Enable internal metrics -{{ macros.config_row(config_metrics, 'enabled', ';enabled = true', 0, true) }} - -# Publish interval -{{ macros.config_row(config_metrics, 'interval_seconds', ';interval_seconds = 10', 0, true) }} - -# Send internal metrics to Graphite -; [metrics.graphite] -; address = localhost:2003 -; prefix = prod.grafana.%(instance_name)s. - -#################################### Internal Grafana Metrics ########################## -# Url used to to import dashboards directly from Grafana.net -[grafana_net] -{{ macros.config_row(config_grafana_net, 'url', 'url = https://grafana.net', 0, true) }} diff --git a/roles/grafana/templates/config/4.0/default.j2 b/roles/grafana/templates/config/4.0/default.j2 deleted file mode 100644 index d103463df..000000000 --- a/roles/grafana/templates/config/4.0/default.j2 +++ /dev/null @@ -1,488 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_grafana_config -%} - -{% set config_paths = [] -%} -{% set config_server = [] -%} -{% set config_database = [] -%} -{% set config_session = [] -%} -{% set config_analytics = [] -%} -{% set config_security = [] -%} -{% set config_snapshots = [] -%} -{% set config_users = [] -%} -{% set config_auth = [] -%} -{% set config_auth_anonymous = [] -%} -{% set config_auth_github = [] -%} -{% set config_auth_google = [] -%} -{% set config_auth_generic_oauth = [] -%} -{% set config_auth_grafananet = [] -%} -{% set config_auth_proxy = [] -%} -{% set config_auth_basic = [] -%} -{% set config_auth_ldap = [] -%} -{% set config_smtp = [] -%} -{% set config_emails = [] -%} -{% set config_log = [] -%} -{% set config_log_console = [] -%} -{% set config_log_file = [] -%} -{% set config_log_syslog = [] -%} -{% set config_event_publisher = [] -%} -{% set config_dashboards_json = [] -%} -{% set config_alerting = [] -%} -{% set config_metrics = [] -%} -{% set config_metrics_graphite = [] -%} -{% set config_grafana_net = [] -%} -{% set config_external_image_storage = [] -%} -{% set config_external_image_storage_s3 = [] -%} -{% set config_external_image_storage_webdav = [] -%} - -{%- for configs in config -%} - {%- for config_name, config_parameters in configs.items() -%} - {%- if config_name == 'paths' -%} - {%- if config_paths.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'server' -%} - {%- if config_server.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'database' -%} - {%- if config_database.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'session' -%} - {%- if config_session.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'analytics' -%} - {%- if config_analytics.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'security' -%} - {%- if config_security.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'snapshots' -%} - {%- if config_snapshots.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'users' -%} - {%- if config_users.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.anonymous' -%} - {%- if config_auth_anonymous.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth' -%} - {%- if config_auth.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.google' -%} - {%- if config_auth_google.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.generic_oauth' -%} - {%- if config_auth_generic_oauth.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.grafananet' -%} - {%- if config_auth_grafananet.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.github' -%} - {%- if config_auth_github.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.proxy' -%} - {%- if config_auth_proxy.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.basic' -%} - {%- if config_auth_basic.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.ldap' -%} - {%- if config_auth_ldap.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'smtp' -%} - {%- if config_smtp.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'emails' -%} - {%- if config_emails.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log' -%} - {%- if config_log.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.console' -%} - {%- if config_log_console.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.file' -%} - {%- if config_log_file.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.syslog' -%} - {%- if config_log_syslog.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'event_publisher' -%} - {%- if config_event_publisher.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'dashboards.json' -%} - {%- if config_dashboards_json.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'alerting' -%} - {%- if config_alerting.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'metrics' -%} - {%- if config_metrics.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'metrics.graphite' -%} - {%- if config_metrics_graphite.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'grafana_net' -%} - {%- if config_grafana_net.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'external_image_storage' -%} - {%- if config_external_image_storage.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'external_image_storage.s3' -%} - {%- if config_external_image_storage_s3.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'external_image_storage.webdav' -%} - {%- if config_external_image_storage_webdav.extend(config_parameters) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} -{%- endfor -%} - - -##################### Grafana Configuration Example ##################### -# -# Everything has defaults so you only need to uncomment things you want to -# change - -# possible values : production, development -{{ macros.config_row(config, 'app_mode', '; app_mode = production', 0, true) }} - -# instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty -{{ macros.config_row(config, 'instance_name', '; instance_name = ${HOSTNAME}', 0, true) }} - -#################################### Paths #################################### -[paths] -# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used) -# -{{ macros.config_row(config_paths, 'data', ';data = /var/lib/grafana', 0, true) }} -# -# Directory where grafana can store logs -# -{{ macros.config_row(config_paths, 'logs', ';logs = /var/log/grafana', 0, true) }} -# -# Directory where grafana will automatically scan and look for plugins -# -{{ macros.config_row(config_paths, 'plugins', ';plugins = /var/lib/grafana/plugins', 0, true) }} - -# -#################################### Server #################################### -[server] -# Protocol (http or https) -{{ macros.config_row(config_server, 'protocol', ';protocol = http', 0, true) }} - -# The ip address to bind to, empty will bind to all interfaces -{{ macros.config_row(config_server, 'http_addr', ';http_addr =', 0, true) }} - -# The http port to use -{{ macros.config_row(config_server, 'http_port', ';http_port = 3000', 0, true) }} - -# The public facing domain name used to access grafana from a browser -{{ macros.config_row(config_server, 'domain', ';domain = localhost', 0, true) }} - -# Redirect to correct domain if host header does not match domain -# Prevents DNS rebinding attacks -{{ macros.config_row(config_server, 'enforce_domain', ';enforce_domain = false', 0, true) }} - -# The full public facing url you use in browser, used for redirects and emails -# If you use reverse proxy and sub path specify full url (with sub path) -{{ macros.config_row(config_server, 'root_url', ';root_url = http://localhost:3000', 0, true) }} - -# Log web requests -{{ macros.config_row(config_server, 'router_logging', ';router_logging = false', 0, true) }} - -# the path relative working path -{{ macros.config_row(config_server, 'static_root_path', ';static_root_path = public', 0, true) }} - -# enable gzip -{{ macros.config_row(config_server, 'enable_gzip', ';enable_gzip = false', 0, true) }} - -# https certs & key file -{{ macros.config_row(config_server, 'cert_file', ';cert_file =', 0, true) }} -{{ macros.config_row(config_server, 'cert_key', ';cert_key =', 0, true) }} - -#################################### Database #################################### -[database] -# You can configure the database connection by specifying type, host, name, user and password -# as seperate properties or as on string using the url propertie. - -# Either "mysql", "postgres" or "sqlite3", it's your choice -{{ macros.config_row(config_database, 'type', ';type = sqlite3', 0, true) }} -{{ macros.config_row(config_database, 'host', ';host = 127.0.0.1:3306', 0, true) }} -{{ macros.config_row(config_database, 'name', ';name = grafana', 0, true) }} -{{ macros.config_row(config_database, 'user', ';user = root', 0, true) }} -{{ macros.config_row(config_database, 'password', ';password =', 0, true) }} - -# Use either URL or the previous fields to configure the database -# Example: mysql://user:secret@host:port/database -{{ macros.config_row(config_database, 'url', ';url =', 0, true) }} - -# For "postgres" only, either "disable", "require" or "verify-full" -{{ macros.config_row(config_database, 'ssl_mode', ';ssl_mode = disable', 0, true) }} - -# For "sqlite3" only, path relative to data_path setting -{{ macros.config_row(config_database, 'path', ';path = grafana.db', 0, true) }} - -#################################### Session #################################### -[session] -# Either "memory", "file", "redis", "mysql", "postgres", default is "file" -{{ macros.config_row(config_session, 'provider', ';provider = file', 0, true) }} - -# Provider config options -# memory: not have any config yet -# file: session dir path, is relative to grafana data_path -# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=grafana` -# mysql: go-sql-driver/mysql dsn config string, e.g. `user:password@tcp(127.0.0.1:3306)/database_name` -# postgres: user=a password=b host=localhost port=5432 dbname=c sslmode=disable -{{ macros.config_row(config_session, 'provider_config', ';provider_config = sessions', 0, true) }} - -# Session cookie name -{{ macros.config_row(config_session, 'cookie_name', ';cookie_name = grafana_sess', 0, true) }} - -# If you use session in https only, default is false -{{ macros.config_row(config_session, 'cookie_secure', ';cookie_secure = false', 0, true) }} - -# Session life time, default is 86400 -{{ macros.config_row(config_session, 'cookie_life_time', ';session_life_time = 86400', 0, true) }} - -#################################### Analytics #################################### -[analytics] -# Server reporting, sends usage counters to stats.grafana.org every 24 hours. -# No ip addresses are being tracked, only simple counters to track -# running instances, dashboard and error counts. It is very helpful to us. -# Change this option to false to disable reporting. -{{ macros.config_row(config_analytics, 'reporting_enabled', ';reporting_enabled = true', 0, true) }} - -# Set to false to disable all checks to https://grafana.net -# for new vesions (grafana itself and plugins), check is used -# in some UI views to notify that grafana or plugin update exists -# This option does not cause any auto updates, nor send any information -# only a GET request to http://grafana.net to get latest versions -{{ macros.config_row(config_analytics, 'check_for_updates', ';check_for_updates = true', 0, true) }} - -# Google Analytics universal tracking code, only enabled if you specify an id here -{{ macros.config_row(config_analytics, 'google_analytics_ua_id', ';google_analytics_ua_id =', 0, true) }} - -#################################### Security #################################### -[security] -# default admin user, created on startup -{{ macros.config_row(config_security, 'admin_user', ';admin_user = admin', 0, true) }} - -# default admin password, can be changed before first start of grafana, or in profile settings -{{ macros.config_row(config_security, 'admin_password', ';admin_password = admin', 0, true) }} - -# used for signing -{{ macros.config_row(config_security, 'secret_key', ';secret_key = SW2YcwTIb9zpOOhoPsMm', 0, true) }} - -# Auto-login remember days -{{ macros.config_row(config_security, 'login_remember_days', ';login_remember_days = 7', 0, true) }} -{{ macros.config_row(config_security, 'cookie_username', ';cookie_username = grafana_user', 0, true) }} -{{ macros.config_row(config_security, 'cookie_remember_name', ';cookie_remember_name = grafana_remember', 0, true) }} - -# disable gravatar profile images -{{ macros.config_row(config_security, 'disable_gravatar', ';disable_gravatar = false', 0, true) }} - -# data source proxy whitelist (ip_or_domain:port separated by spaces) -{{ macros.config_row(config_security, 'data_source_proxy_whitelist', ';data_source_proxy_whitelist =', 0, true) }} - -[snapshots] -# snapshot sharing options -{{ macros.config_row(config_snapshots, 'external_enabled', ';external_enabled = true', 0, true) }} -{{ macros.config_row(config_snapshots, 'external_snapshot_url', ';external_snapshot_url = https://snapshots-origin.raintank.io', 0, true) }} -{{ macros.config_row(config_snapshots, 'external_snapshot_name', ';external_snapshot_name = Publish to snapshot.raintank.io', 0, true) }} - -# remove expired snapshot -{{ macros.config_row(config_snapshots, 'snapshot_remove_expired', ';snapshot_remove_expired = true', 0, true) }} - -# remove snapshots after 90 days -{{ macros.config_row(config_snapshots, 'snapshot_TTL_days', ';snapshot_TTL_days = 90', 0, true) }} - -#################################### Users #################################### -[users] -# disable user signup / registration -{{ macros.config_row(config_users, 'allow_sign_up', ';allow_sign_up = true', 0, true) }} - -# Allow non admin users to create organizations -{{ macros.config_row(config_users, 'allow_org_create', ';allow_org_create = true', 0, true) }} - -# Set to true to automatically assign new users to the default organization (id 1) -{{ macros.config_row(config_users, 'auto_assign_org', ';auto_assign_org = true', 0, true) }} - -# Default role new users will be automatically assigned (if disabled above is set to true) -{{ macros.config_row(config_users, 'auto_assign_org_role', ';auto_assign_org_role = Viewer', 0, true) }} - -# Background text for the user field on the login page -{{ macros.config_row(config_users, 'login_hint', ';login_hint = email or username', 0, true) }} - -# Default UI theme ("dark" or "light") -{{ macros.config_row(config_users, 'default_theme', ';default_theme = dark', 0, true) }} - -[auth] -# Set to true to disable (hide) the login form, useful if you use OAuth, defaults to false -{{ macros.config_row(config_auth, 'disable_login_form', ';disable_login_form = false', 0, true) }} - -#################################### Anonymous Auth ########################## -[auth.anonymous] -# enable anonymous access -{{ macros.config_row(config_auth_anonymous, 'enabled', ';enabled = false', 0, true) }} - -# specify organization name that should be used for unauthenticated users -{{ macros.config_row(config_auth_anonymous, 'org_name', ';org_name = Main Org.', 0, true) }} - -# specify role for unauthenticated users -{{ macros.config_row(config_auth_anonymous, 'org_role', ';org_role = Viewer', 0, true) }} - -#################################### Github Auth ########################## -[auth.github] -{{ macros.config_row(config_auth_github, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_github, 'allow_sign_up', ';allow_sign_up = false', 0, true) }} -{{ macros.config_row(config_auth_github, 'client_id', ';client_id = some_id', 0, true) }} -{{ macros.config_row(config_auth_github, 'client_secret', ';client_secret = some_secret', 0, true) }} -{{ macros.config_row(config_auth_github, 'scopes', ';scopes = user:email,read:org', 0, true) }} -{{ macros.config_row(config_auth_github, 'auth_url', ';auth_url = https://github.com/login/oauth/authorize', 0, true) }} -{{ macros.config_row(config_auth_github, 'token_url', ';token_url = https://github.com/login/oauth/access_token', 0, true) }} -{{ macros.config_row(config_auth_github, 'api_url', ';api_url = https://api.github.com/user', 0, true) }} -{{ macros.config_row(config_auth_github, 'team_ids', ';team_ids =', 0, true) }} -{{ macros.config_row(config_auth_github, 'allowed_organizations', ';allowed_organizations =', 0, true) }} - -#################################### Google Auth ########################## -[auth.google] -{{ macros.config_row(config_auth_google, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_google, 'allow_sign_up', ';allow_sign_up = false', 0, true) }} -{{ macros.config_row(config_auth_google, 'client_id', ';client_id = some_client_id', 0, true) }} -{{ macros.config_row(config_auth_google, 'client_secret', ';client_secret = some_client_secret', 0, true) }} -{{ macros.config_row(config_auth_google, 'scopes', ';scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email', 0, true) }} -{{ macros.config_row(config_auth_google, 'auth_url', ';auth_url = https://accounts.google.com/o/oauth2/auth', 0, true) }} -{{ macros.config_row(config_auth_google, 'token_url', ';token_url = https://accounts.google.com/o/oauth2/token', 0, true) }} -{{ macros.config_row(config_auth_google, 'api_url', ';api_url = https://www.googleapis.com/oauth2/v1/userinfo', 0, true) }} -{{ macros.config_row(config_auth_google, 'allowed_domains', ';allowed_domains =', 0, true) }} - -#################################### Generic OAuth ########################## -[auth.generic_oauth] -{{ macros.config_row(config_auth_generic_oauth, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'allow_sign_up', ';allow_sign_up = false', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'client_id', ';client_id = some_id', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'client_secret', ';client_secret = some_secret', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'scopes', ';scopes = user:email,read:org', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'auth_url', ';auth_url = https://foo.bar/login/oauth/authorize', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'token_url', ';token_url = https://foo.bar/login/oauth/access_token', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'api_url', ';api_url = https://foo.bar/user', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'team_ids', ';team_ids =', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'allowed_organizations', ';allowed_organizations =', 0, true) }} - -#################################### Grafana.net Auth #################### -[auth.grafananet] -{{ macros.config_row(config_auth_grafananet, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_grafananet, 'allow_sign_up', ';allow_sign_up = false', 0, true) }} -{{ macros.config_row(config_auth_grafananet, 'client_id', ';client_id = some_id', 0, true) }} -{{ macros.config_row(config_auth_grafananet, 'client_secret', ';client_secret = some_secret', 0, true) }} -{{ macros.config_row(config_auth_grafananet, 'scopes', ';scopes = user:email', 0, true) }} -{{ macros.config_row(config_auth_grafananet, 'allowed_organizations', ';allowed_organizations =', 0, true) }} - -#################################### Auth Proxy ########################## -[auth.proxy] -{{ macros.config_row(config_auth_proxy, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'header_name', ';header_name = X-WEBAUTH-USER', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'header_property', ';header_property = username', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'auto_sign_up', ';auto_sign_up = true', 0, true) }} - -#################################### Basic Auth ########################## -[auth.basic] -{{ macros.config_row(config_auth_basic, 'enabled', ';enabled = true', 0, true) }} - -#################################### Auth LDAP ########################## -[auth.ldap] -{{ macros.config_row(config_auth_ldap, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_ldap, 'config_file', ';config_file = /etc/grafana/ldap.toml', 0, true) }} -{{ macros.config_row(config_auth_ldap, 'allow_sign_up', ';allow_sign_up = true', 0, true) }} - -#################################### SMTP / Emailing ########################## -[smtp] -{{ macros.config_row(config_smtp, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_smtp, 'host', ';host = localhost:25', 0, true) }} -{{ macros.config_row(config_smtp, 'user', ';user =', 0, true) }} -{{ macros.config_row(config_smtp, 'password', ';password =', 0, true) }} -{{ macros.config_row(config_smtp, 'cert_file', ';cert_file =', 0, true) }} -{{ macros.config_row(config_smtp, 'key_file', ';key_file =', 0, true) }} -{{ macros.config_row(config_smtp, 'skip_verify', ';skip_verify = false', 0, true) }} -{{ macros.config_row(config_smtp, 'from_address', ';from_address = admin@grafana.localhost', 0, true) }} - -[emails] -{{ macros.config_row(config_emails, 'welcome_email_on_sign_up', ';welcome_email_on_sign_up = false', 0, true) }} - -#################################### Logging ########################## -[log] -# Either "console", "file", "syslog". Default is console and file -# Use space to separate multiple modes, e.g. "console file" -{{ macros.config_row(config_log, 'mode', ';mode = console, file', 0, true) }} - -# Either "trace", "debug", "info", "warn", "error", "critical", default is "info" -{{ macros.config_row(config_log, 'level', ';level = info', 0, true) }} - -# optional settings to set different levels for specific loggers. Ex filters = sqlstore:debug -{{ macros.config_row(config_log, 'filters', ';filters =', 0, true) }} - - -# For "console" mode only -[log.console] -{{ macros.config_row(config_log_console, 'level', ';level =', 0, true) }} - -# log line format, valid options are text, console and json -{{ macros.config_row(config_log_console, 'format', ';format = console', 0, true) }} - -# For "file" mode only -[log.file] -{{ macros.config_row(config_log_file, 'level', ';level =', 0, true) }} - -# log line format, valid options are text, console and json -{{ macros.config_row(config_log_file, 'format', ';format = text', 0, true) }} - -# This enables automated log rotate(switch of following options), default is true -{{ macros.config_row(config_log_file, 'log_rotate', ';log_rotate = true', 0, true) }} - -# Max line number of single file, default is 1000000 -{{ macros.config_row(config_log_file, 'max_lines', ';max_lines = 1000000', 0, true) }} - -# Max size shift of single file, default is 28 means 1 << 28, 256MB -{{ macros.config_row(config_log_file, 'max_size_shift', ';max_size_shift = 28', 0, true) }} - -# Segment log daily, default is true -{{ macros.config_row(config_log_file, 'daily_rotate', ';daily_rotate = true', 0, true) }} - -# Expired days of log file(delete after max days), default is 7 -{{ macros.config_row(config_log_file, 'max_days', ';max_days = 7', 0, true) }} - -[log.syslog] -{{ macros.config_row(config_log_syslog, 'level', ';level =', 0, true) }} - -# log line format, valid options are text, console and json -{{ macros.config_row(config_log_syslog, 'format', ';format = text', 0, true) }} - -# Syslog network type and address. This can be udp, tcp, or unix. If left blank, the default unix endpoints will be used. -{{ macros.config_row(config_log_syslog, 'network', ';network =', 0, true) }} -{{ macros.config_row(config_log_syslog, 'address', ';address =', 0, true) }} - -# Syslog facility. user, daemon and local0 through local7 are valid. -{{ macros.config_row(config_log_syslog, 'facility', ';facility =', 0, true) }} - -# Syslog tag. By default, the process' argv[0] is used. -{{ macros.config_row(config_log_syslog, 'tag', ';tag =', 0, true) }} - - -#################################### AMQP Event Publisher ########################## -[event_publisher] -{{ macros.config_row(config_event_publisher, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_event_publisher, 'rabbitmq_url', ';rabbitmq_url = amqp://localhost/', 0, true) }} -{{ macros.config_row(config_event_publisher, 'exchange', ';exchange = grafana_events', 0, true) }} - -;#################################### Dashboard JSON files ########################## -[dashboards.json] -{{ macros.config_row(config_dashboards_json, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_dashboards_json, 'path', ';path = /var/lib/grafana/dashboards', 0, true) }} - -#################################### Alerting ###################################### -[alerting] -# Makes it possible to turn off alert rule execution. -{{ macros.config_row(config_alerting, 'execute_alerts', ';execute_alerts = true', 0, true) }} - -#################################### Internal Grafana Metrics ########################## -# Metrics available at HTTP API Url /api/metrics -[metrics] -# Disable / Enable internal metrics -{{ macros.config_row(config_metrics, 'enabled', ';enabled = true', 0, true) }} - -# Publish interval -{{ macros.config_row(config_metrics, 'interval_seconds', ';interval_seconds = 10', 0, true) }} - -# Send internal metrics to Graphite -[metrics.graphite] -# Enable by setting the address setting (ex localhost:2003) -{{ macros.config_row(config_metrics_graphite, 'address', ';address =', 0, true) }} -{{ macros.config_row(config_metrics_graphite, 'prefix', ';prefix = prod.grafana.%(instance_name)s.', 0, true) }} - -#################################### Internal Grafana Metrics ########################## -# Url used to to import dashboards directly from Grafana.net -[grafana_net] -{{ macros.config_row(config_grafana_net, 'url', ';url = https://grafana.net', 0, true) }} - -#################################### External image storage ########################## -[external_image_storage] -# Used for uploading images to public servers so they can be included in slack/email messages. -# you can choose between (s3, webdav) -{{ macros.config_row(config_external_image_storage, 'provider', ';provider =', 0, true) }} - -[external_image_storage.s3] -{{ macros.config_row(config_external_image_storage_s3, 'bucket_url', ';bucket_url =', 0, true) }} -{{ macros.config_row(config_external_image_storage_s3, 'access_key', ';access_key =', 0, true) }} -{{ macros.config_row(config_external_image_storage_s3, 'secret_key', ';secret_key =', 0, true) }} - -[external_image_storage.webdav] -{{ macros.config_row(config_external_image_storage_webdav, 'url', ';url =', 0, true) }} -{{ macros.config_row(config_external_image_storage_webdav, 'username', ';username =', 0, true) }} -{{ macros.config_row(config_external_image_storage_webdav, 'password', ';password =', 0, true) }} diff --git a/roles/grafana/templates/config/4.1/default.j2 b/roles/grafana/templates/config/4.1/default.j2 deleted file mode 100644 index bc4021045..000000000 --- a/roles/grafana/templates/config/4.1/default.j2 +++ /dev/null @@ -1,492 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_grafana_config -%} - -{% set config_paths = [] -%} -{% set config_server = [] -%} -{% set config_database = [] -%} -{% set config_session = [] -%} -{% set config_analytics = [] -%} -{% set config_security = [] -%} -{% set config_snapshots = [] -%} -{% set config_users = [] -%} -{% set config_auth = [] -%} -{% set config_auth_anonymous = [] -%} -{% set config_auth_github = [] -%} -{% set config_auth_google = [] -%} -{% set config_auth_generic_oauth = [] -%} -{% set config_auth_grafananet = [] -%} -{% set config_auth_proxy = [] -%} -{% set config_auth_basic = [] -%} -{% set config_auth_ldap = [] -%} -{% set config_smtp = [] -%} -{% set config_emails = [] -%} -{% set config_log = [] -%} -{% set config_log_console = [] -%} -{% set config_log_file = [] -%} -{% set config_log_syslog = [] -%} -{% set config_event_publisher = [] -%} -{% set config_dashboards_json = [] -%} -{% set config_alerting = [] -%} -{% set config_metrics = [] -%} -{% set config_metrics_graphite = [] -%} -{% set config_grafana_net = [] -%} -{% set config_external_image_storage = [] -%} -{% set config_external_image_storage_s3 = [] -%} -{% set config_external_image_storage_webdav = [] -%} - -{%- for configs in config -%} - {%- for config_name, config_parameters in configs.items() -%} - {%- if config_name == 'paths' -%} - {%- if config_paths.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'server' -%} - {%- if config_server.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'database' -%} - {%- if config_database.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'session' -%} - {%- if config_session.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'analytics' -%} - {%- if config_analytics.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'security' -%} - {%- if config_security.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'snapshots' -%} - {%- if config_snapshots.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'users' -%} - {%- if config_users.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.anonymous' -%} - {%- if config_auth_anonymous.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth' -%} - {%- if config_auth.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.google' -%} - {%- if config_auth_google.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.generic_oauth' -%} - {%- if config_auth_generic_oauth.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.grafananet' -%} - {%- if config_auth_grafananet.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.github' -%} - {%- if config_auth_github.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.proxy' -%} - {%- if config_auth_proxy.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.basic' -%} - {%- if config_auth_basic.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.ldap' -%} - {%- if config_auth_ldap.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'smtp' -%} - {%- if config_smtp.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'emails' -%} - {%- if config_emails.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log' -%} - {%- if config_log.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.console' -%} - {%- if config_log_console.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.file' -%} - {%- if config_log_file.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.syslog' -%} - {%- if config_log_syslog.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'event_publisher' -%} - {%- if config_event_publisher.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'dashboards.json' -%} - {%- if config_dashboards_json.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'alerting' -%} - {%- if config_alerting.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'metrics' -%} - {%- if config_metrics.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'metrics.graphite' -%} - {%- if config_metrics_graphite.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'grafana_net' -%} - {%- if config_grafana_net.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'external_image_storage' -%} - {%- if config_external_image_storage.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'external_image_storage.s3' -%} - {%- if config_external_image_storage_s3.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'external_image_storage.webdav' -%} - {%- if config_external_image_storage_webdav.extend(config_parameters) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} -{%- endfor -%} - - -##################### Grafana Configuration Example ##################### -# -# Everything has defaults so you only need to uncomment things you want to -# change - -# possible values : production, development -{{ macros.config_row(config, 'app_mode', '; app_mode = production', 0, true) }} - -# instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty -{{ macros.config_row(config, 'instance_name', '; instance_name = ${HOSTNAME}', 0, true) }} - -#################################### Paths #################################### -[paths] -# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used) -# -{{ macros.config_row(config_paths, 'data', ';data = /var/lib/grafana', 0, true) }} -# -# Directory where grafana can store logs -# -{{ macros.config_row(config_paths, 'logs', ';logs = /var/log/grafana', 0, true) }} -# -# Directory where grafana will automatically scan and look for plugins -# -{{ macros.config_row(config_paths, 'plugins', ';plugins = /var/lib/grafana/plugins', 0, true) }} - -# -#################################### Server #################################### -[server] -# Protocol (http or https) -{{ macros.config_row(config_server, 'protocol', ';protocol = http', 0, true) }} - -# The ip address to bind to, empty will bind to all interfaces -{{ macros.config_row(config_server, 'http_addr', ';http_addr =', 0, true) }} - -# The http port to use -{{ macros.config_row(config_server, 'http_port', ';http_port = 3000', 0, true) }} - -# The public facing domain name used to access grafana from a browser -{{ macros.config_row(config_server, 'domain', ';domain = localhost', 0, true) }} - -# Redirect to correct domain if host header does not match domain -# Prevents DNS rebinding attacks -{{ macros.config_row(config_server, 'enforce_domain', ';enforce_domain = false', 0, true) }} - -# The full public facing url you use in browser, used for redirects and emails -# If you use reverse proxy and sub path specify full url (with sub path) -{{ macros.config_row(config_server, 'root_url', ';root_url = http://localhost:3000', 0, true) }} - -# Log web requests -{{ macros.config_row(config_server, 'router_logging', ';router_logging = false', 0, true) }} - -# the path relative working path -{{ macros.config_row(config_server, 'static_root_path', ';static_root_path = public', 0, true) }} - -# enable gzip -{{ macros.config_row(config_server, 'enable_gzip', ';enable_gzip = false', 0, true) }} - -# https certs & key file -{{ macros.config_row(config_server, 'cert_file', ';cert_file =', 0, true) }} -{{ macros.config_row(config_server, 'cert_key', ';cert_key =', 0, true) }} - -#################################### Database #################################### -[database] -# You can configure the database connection by specifying type, host, name, user and password -# as seperate properties or as on string using the url propertie. - -# Either "mysql", "postgres" or "sqlite3", it's your choice -{{ macros.config_row(config_database, 'type', ';type = sqlite3', 0, true) }} -{{ macros.config_row(config_database, 'host', ';host = 127.0.0.1:3306', 0, true) }} -{{ macros.config_row(config_database, 'name', ';name = grafana', 0, true) }} -{{ macros.config_row(config_database, 'user', ';user = root', 0, true) }} -# If the password contains # or ; you have to wrap it with trippel quotes. Ex """#password;""" -{{ macros.config_row(config_database, 'password', ';password =', 0, true) }} - -# Use either URL or the previous fields to configure the database -# Example: mysql://user:secret@host:port/database -{{ macros.config_row(config_database, 'url', ';url =', 0, true) }} - -# For "postgres" only, either "disable", "require" or "verify-full" -{{ macros.config_row(config_database, 'ssl_mode', ';ssl_mode = disable', 0, true) }} - -# For "sqlite3" only, path relative to data_path setting -{{ macros.config_row(config_database, 'path', ';path = grafana.db', 0, true) }} - -#################################### Session #################################### -[session] -# Either "memory", "file", "redis", "mysql", "postgres", default is "file" -{{ macros.config_row(config_session, 'provider', ';provider = file', 0, true) }} - -# Provider config options -# memory: not have any config yet -# file: session dir path, is relative to grafana data_path -# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=grafana` -# mysql: go-sql-driver/mysql dsn config string, e.g. `user:password@tcp(127.0.0.1:3306)/database_name` -# postgres: user=a password=b host=localhost port=5432 dbname=c sslmode=disable -{{ macros.config_row(config_session, 'provider_config', ';provider_config = sessions', 0, true) }} - -# Session cookie name -{{ macros.config_row(config_session, 'cookie_name', ';cookie_name = grafana_sess', 0, true) }} - -# If you use session in https only, default is false -{{ macros.config_row(config_session, 'cookie_secure', ';cookie_secure = false', 0, true) }} - -# Session life time, default is 86400 -{{ macros.config_row(config_session, 'cookie_life_time', ';session_life_time = 86400', 0, true) }} - -#################################### Analytics #################################### -[analytics] -# Server reporting, sends usage counters to stats.grafana.org every 24 hours. -# No ip addresses are being tracked, only simple counters to track -# running instances, dashboard and error counts. It is very helpful to us. -# Change this option to false to disable reporting. -{{ macros.config_row(config_analytics, 'reporting_enabled', ';reporting_enabled = true', 0, true) }} - -# Set to false to disable all checks to https://grafana.net -# for new vesions (grafana itself and plugins), check is used -# in some UI views to notify that grafana or plugin update exists -# This option does not cause any auto updates, nor send any information -# only a GET request to http://grafana.net to get latest versions -{{ macros.config_row(config_analytics, 'check_for_updates', ';check_for_updates = true', 0, true) }} - -# Google Analytics universal tracking code, only enabled if you specify an id here -{{ macros.config_row(config_analytics, 'google_analytics_ua_id', ';google_analytics_ua_id =', 0, true) }} - -#################################### Security #################################### -[security] -# default admin user, created on startup -{{ macros.config_row(config_security, 'admin_user', ';admin_user = admin', 0, true) }} - -# default admin password, can be changed before first start of grafana, or in profile settings -{{ macros.config_row(config_security, 'admin_password', ';admin_password = admin', 0, true) }} - -# used for signing -{{ macros.config_row(config_security, 'secret_key', ';secret_key = SW2YcwTIb9zpOOhoPsMm', 0, true) }} - -# Auto-login remember days -{{ macros.config_row(config_security, 'login_remember_days', ';login_remember_days = 7', 0, true) }} -{{ macros.config_row(config_security, 'cookie_username', ';cookie_username = grafana_user', 0, true) }} -{{ macros.config_row(config_security, 'cookie_remember_name', ';cookie_remember_name = grafana_remember', 0, true) }} - -# disable gravatar profile images -{{ macros.config_row(config_security, 'disable_gravatar', ';disable_gravatar = false', 0, true) }} - -# data source proxy whitelist (ip_or_domain:port separated by spaces) -{{ macros.config_row(config_security, 'data_source_proxy_whitelist', ';data_source_proxy_whitelist =', 0, true) }} - -[snapshots] -# snapshot sharing options -{{ macros.config_row(config_snapshots, 'external_enabled', ';external_enabled = true', 0, true) }} -{{ macros.config_row(config_snapshots, 'external_snapshot_url', ';external_snapshot_url = https://snapshots-origin.raintank.io', 0, true) }} -{{ macros.config_row(config_snapshots, 'external_snapshot_name', ';external_snapshot_name = Publish to snapshot.raintank.io', 0, true) }} - -# remove expired snapshot -{{ macros.config_row(config_snapshots, 'snapshot_remove_expired', ';snapshot_remove_expired = true', 0, true) }} - -# remove snapshots after 90 days -{{ macros.config_row(config_snapshots, 'snapshot_TTL_days', ';snapshot_TTL_days = 90', 0, true) }} - -#################################### Users #################################### -[users] -# disable user signup / registration -{{ macros.config_row(config_users, 'allow_sign_up', ';allow_sign_up = true', 0, true) }} - -# Allow non admin users to create organizations -{{ macros.config_row(config_users, 'allow_org_create', ';allow_org_create = true', 0, true) }} - -# Set to true to automatically assign new users to the default organization (id 1) -{{ macros.config_row(config_users, 'auto_assign_org', ';auto_assign_org = true', 0, true) }} - -# Default role new users will be automatically assigned (if disabled above is set to true) -{{ macros.config_row(config_users, 'auto_assign_org_role', ';auto_assign_org_role = Viewer', 0, true) }} - -# Background text for the user field on the login page -{{ macros.config_row(config_users, 'login_hint', ';login_hint = email or username', 0, true) }} - -# Default UI theme ("dark" or "light") -{{ macros.config_row(config_users, 'default_theme', ';default_theme = dark', 0, true) }} - -[auth] -# Set to true to disable (hide) the login form, useful if you use OAuth, defaults to false -{{ macros.config_row(config_auth, 'disable_login_form', ';disable_login_form = false', 0, true) }} - -#################################### Anonymous Auth ########################## -[auth.anonymous] -# enable anonymous access -{{ macros.config_row(config_auth_anonymous, 'enabled', ';enabled = false', 0, true) }} - -# specify organization name that should be used for unauthenticated users -{{ macros.config_row(config_auth_anonymous, 'org_name', ';org_name = Main Org.', 0, true) }} - -# specify role for unauthenticated users -{{ macros.config_row(config_auth_anonymous, 'org_role', ';org_role = Viewer', 0, true) }} - -#################################### Github Auth ########################## -[auth.github] -{{ macros.config_row(config_auth_github, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_github, 'allow_sign_up', ';allow_sign_up = true', 0, true) }} -{{ macros.config_row(config_auth_github, 'client_id', ';client_id = some_id', 0, true) }} -{{ macros.config_row(config_auth_github, 'client_secret', ';client_secret = some_secret', 0, true) }} -{{ macros.config_row(config_auth_github, 'scopes', ';scopes = user:email,read:org', 0, true) }} -{{ macros.config_row(config_auth_github, 'auth_url', ';auth_url = https://github.com/login/oauth/authorize', 0, true) }} -{{ macros.config_row(config_auth_github, 'token_url', ';token_url = https://github.com/login/oauth/access_token', 0, true) }} -{{ macros.config_row(config_auth_github, 'api_url', ';api_url = https://api.github.com/user', 0, true) }} -{{ macros.config_row(config_auth_github, 'team_ids', ';team_ids =', 0, true) }} -{{ macros.config_row(config_auth_github, 'allowed_organizations', ';allowed_organizations =', 0, true) }} - -#################################### Google Auth ########################## -[auth.google] -{{ macros.config_row(config_auth_google, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_google, 'allow_sign_up', ';allow_sign_up = true', 0, true) }} -{{ macros.config_row(config_auth_google, 'client_id', ';client_id = some_client_id', 0, true) }} -{{ macros.config_row(config_auth_google, 'client_secret', ';client_secret = some_client_secret', 0, true) }} -{{ macros.config_row(config_auth_google, 'scopes', ';scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email', 0, true) }} -{{ macros.config_row(config_auth_google, 'auth_url', ';auth_url = https://accounts.google.com/o/oauth2/auth', 0, true) }} -{{ macros.config_row(config_auth_google, 'token_url', ';token_url = https://accounts.google.com/o/oauth2/token', 0, true) }} -{{ macros.config_row(config_auth_google, 'api_url', ';api_url = https://www.googleapis.com/oauth2/v1/userinfo', 0, true) }} -{{ macros.config_row(config_auth_google, 'allowed_domains', ';allowed_domains =', 0, true) }} - -#################################### Generic OAuth ########################## -[auth.generic_oauth] -{{ macros.config_row(config_auth_generic_oauth, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'name', ';name = OAuth', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'allow_sign_up', ';allow_sign_up = true', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'client_id', ';client_id = some_id', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'client_secret', ';client_secret = some_secret', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'scopes', ';scopes = user:email,read:org', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'auth_url', ';auth_url = https://foo.bar/login/oauth/authorize', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'token_url', ';token_url = https://foo.bar/login/oauth/access_token', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'api_url', ';api_url = https://foo.bar/user', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'team_ids', ';team_ids =', 0, true) }} -{{ macros.config_row(config_auth_generic_oauth, 'allowed_organizations', ';allowed_organizations =', 0, true) }} - -#################################### Grafana.net Auth #################### -[auth.grafananet] -{{ macros.config_row(config_auth_grafananet, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_grafananet, 'allow_sign_up', ';allow_sign_up = true', 0, true) }} -{{ macros.config_row(config_auth_grafananet, 'client_id', ';client_id = some_id', 0, true) }} -{{ macros.config_row(config_auth_grafananet, 'client_secret', ';client_secret = some_secret', 0, true) }} -{{ macros.config_row(config_auth_grafananet, 'scopes', ';scopes = user:email', 0, true) }} -{{ macros.config_row(config_auth_grafananet, 'allowed_organizations', ';allowed_organizations =', 0, true) }} - -#################################### Auth Proxy ########################## -[auth.proxy] -{{ macros.config_row(config_auth_proxy, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'header_name', ';header_name = X-WEBAUTH-USER', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'header_property', ';header_property = username', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'auto_sign_up', ';auto_sign_up = true', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'ldap_sync_ttl', ';ldap_sync_ttl = 60', 0, true) }} -{{ macros.config_row(config_auth_proxy, 'whitelist', ';whitelist = 192.168.1.1, 192.168.2.1', 0, true) }} - -#################################### Basic Auth ########################## -[auth.basic] -{{ macros.config_row(config_auth_basic, 'enabled', ';enabled = true', 0, true) }} - -#################################### Auth LDAP ########################## -[auth.ldap] -{{ macros.config_row(config_auth_ldap, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_auth_ldap, 'config_file', ';config_file = /etc/grafana/ldap.toml', 0, true) }} -{{ macros.config_row(config_auth_ldap, 'allow_sign_up', ';allow_sign_up = true', 0, true) }} - -#################################### SMTP / Emailing ########################## -[smtp] -{{ macros.config_row(config_smtp, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_smtp, 'host', ';host = localhost:25', 0, true) }} -{{ macros.config_row(config_smtp, 'user', ';user =', 0, true) }} -{{ macros.config_row(config_smtp, 'password', ';password =', 0, true) }} -{{ macros.config_row(config_smtp, 'cert_file', ';cert_file =', 0, true) }} -{{ macros.config_row(config_smtp, 'key_file', ';key_file =', 0, true) }} -{{ macros.config_row(config_smtp, 'skip_verify', ';skip_verify = false', 0, true) }} -{{ macros.config_row(config_smtp, 'from_address', ';from_address = admin@grafana.localhost', 0, true) }} - -[emails] -{{ macros.config_row(config_emails, 'welcome_email_on_sign_up', ';welcome_email_on_sign_up = false', 0, true) }} - -#################################### Logging ########################## -[log] -# Either "console", "file", "syslog". Default is console and file -# Use space to separate multiple modes, e.g. "console file" -{{ macros.config_row(config_log, 'mode', ';mode = console file', 0, true) }} - -# Either "trace", "debug", "info", "warn", "error", "critical", default is "info" -{{ macros.config_row(config_log, 'level', ';level = info', 0, true) }} - -# optional settings to set different levels for specific loggers. Ex filters = sqlstore:debug -{{ macros.config_row(config_log, 'filters', ';filters =', 0, true) }} - - -# For "console" mode only -[log.console] -{{ macros.config_row(config_log_console, 'level', ';level =', 0, true) }} - -# log line format, valid options are text, console and json -{{ macros.config_row(config_log_console, 'format', ';format = console', 0, true) }} - -# For "file" mode only -[log.file] -{{ macros.config_row(config_log_file, 'level', ';level =', 0, true) }} - -# log line format, valid options are text, console and json -{{ macros.config_row(config_log_file, 'format', ';format = text', 0, true) }} - -# This enables automated log rotate(switch of following options), default is true -{{ macros.config_row(config_log_file, 'log_rotate', ';log_rotate = true', 0, true) }} - -# Max line number of single file, default is 1000000 -{{ macros.config_row(config_log_file, 'max_lines', ';max_lines = 1000000', 0, true) }} - -# Max size shift of single file, default is 28 means 1 << 28, 256MB -{{ macros.config_row(config_log_file, 'max_size_shift', ';max_size_shift = 28', 0, true) }} - -# Segment log daily, default is true -{{ macros.config_row(config_log_file, 'daily_rotate', ';daily_rotate = true', 0, true) }} - -# Expired days of log file(delete after max days), default is 7 -{{ macros.config_row(config_log_file, 'max_days', ';max_days = 7', 0, true) }} - -[log.syslog] -{{ macros.config_row(config_log_syslog, 'level', ';level =', 0, true) }} - -# log line format, valid options are text, console and json -{{ macros.config_row(config_log_syslog, 'format', ';format = text', 0, true) }} - -# Syslog network type and address. This can be udp, tcp, or unix. If left blank, the default unix endpoints will be used. -{{ macros.config_row(config_log_syslog, 'network', ';network =', 0, true) }} -{{ macros.config_row(config_log_syslog, 'address', ';address =', 0, true) }} - -# Syslog facility. user, daemon and local0 through local7 are valid. -{{ macros.config_row(config_log_syslog, 'facility', ';facility =', 0, true) }} - -# Syslog tag. By default, the process' argv[0] is used. -{{ macros.config_row(config_log_syslog, 'tag', ';tag =', 0, true) }} - - -#################################### AMQP Event Publisher ########################## -[event_publisher] -{{ macros.config_row(config_event_publisher, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_event_publisher, 'rabbitmq_url', ';rabbitmq_url = amqp://localhost/', 0, true) }} -{{ macros.config_row(config_event_publisher, 'exchange', ';exchange = grafana_events', 0, true) }} - -;#################################### Dashboard JSON files ########################## -[dashboards.json] -{{ macros.config_row(config_dashboards_json, 'enabled', ';enabled = false', 0, true) }} -{{ macros.config_row(config_dashboards_json, 'path', ';path = /var/lib/grafana/dashboards', 0, true) }} - -#################################### Alerting ###################################### -[alerting] -# Makes it possible to turn off alert rule execution. -{{ macros.config_row(config_alerting, 'execute_alerts', ';execute_alerts = true', 0, true) }} - -#################################### Internal Grafana Metrics ########################## -# Metrics available at HTTP API Url /api/metrics -[metrics] -# Disable / Enable internal metrics -{{ macros.config_row(config_metrics, 'enabled', ';enabled = true', 0, true) }} - -# Publish interval -{{ macros.config_row(config_metrics, 'interval_seconds', ';interval_seconds = 10', 0, true) }} - -# Send internal metrics to Graphite -[metrics.graphite] -# Enable by setting the address setting (ex localhost:2003) -{{ macros.config_row(config_metrics_graphite, 'address', ';address =', 0, true) }} -{{ macros.config_row(config_metrics_graphite, 'prefix', ';prefix = prod.grafana.%(instance_name)s.', 0, true) }} - -#################################### Internal Grafana Metrics ########################## -# Url used to to import dashboards directly from Grafana.net -[grafana_net] -{{ macros.config_row(config_grafana_net, 'url', ';url = https://grafana.net', 0, true) }} - -#################################### External image storage ########################## -[external_image_storage] -# Used for uploading images to public servers so they can be included in slack/email messages. -# you can choose between (s3, webdav) -{{ macros.config_row(config_external_image_storage, 'provider', ';provider =', 0, true) }} - -[external_image_storage.s3] -{{ macros.config_row(config_external_image_storage_s3, 'bucket_url', ';bucket_url =', 0, true) }} -{{ macros.config_row(config_external_image_storage_s3, 'access_key', ';access_key =', 0, true) }} -{{ macros.config_row(config_external_image_storage_s3, 'secret_key', ';secret_key =', 0, true) }} - -[external_image_storage.webdav] -{{ macros.config_row(config_external_image_storage_webdav, 'url', ';url =', 0, true) }} -{{ macros.config_row(config_external_image_storage_webdav, 'username', ';username =', 0, true) }} -{{ macros.config_row(config_external_image_storage_webdav, 'password', ';password =', 0, true) }} diff --git a/roles/grafana/templates/config/6.2/default.j2 b/roles/grafana/templates/config/6.2/default.j2 deleted file mode 100644 index 3f55db181..000000000 --- a/roles/grafana/templates/config/6.2/default.j2 +++ /dev/null @@ -1,664 +0,0 @@ -{%- import '_macros.j2' as macros with context -%} - -{% set config = manala_grafana_config -%} - -{% set config_paths = [] -%} -{% set config_server = [] -%} -{% set config_database = [] -%} -{% set config_remote_cache = [] -%} -{% set config_dataproxy = [] -%} -{% set config_analytics = [] -%} -{% set config_security = [] -%} -{% set config_snapshots = [] -%} -{% set config_dashboards = [] -%} -{% set config_users = [] -%} -{% set config_auth = [] -%} -{% set config_auth_anonymous = [] -%} -{% set config_auth_github = [] -%} -{% set config_auth_google = [] -%} -{% set config_auth_generic_oauth = [] -%} -{% set config_auth_grafana_com = [] -%} -{% set config_auth_proxy = [] -%} -{% set config_auth_basic = [] -%} -{% set config_auth_ldap = [] -%} -{% set config_smtp = [] -%} -{% set config_emails = [] -%} -{% set config_log = [] -%} -{% set config_log_console = [] -%} -{% set config_log_file = [] -%} -{% set config_log_syslog = [] -%} -{% set config_alerting = [] -%} -{% set config_explore = [] -%} -{% set config_metrics = [] -%} -{% set config_metrics_graphite = [] -%} -{% set config_tracing_jaeger = [] -%} -{% set config_grafana_com = [] -%} -{% set config_external_image_storage = [] -%} -{% set config_external_image_storage_s3 = [] -%} -{% set config_external_image_storage_webdav = [] -%} -{% set config_external_image_storage_gcs = [] -%} -{% set config_external_image_storage_azure_blob = [] -%} -{% set config_external_image_storage_local = [] -%} -{% set config_rendering = [] -%} -{% set config_enterprise = [] -%} -{% set config_panels = [] -%} -{% set config_plugins = [] -%} - -{%- for configs in config -%} - {%- for config_name, config_parameters in configs.items() -%} - {%- if config_name == 'paths' -%} - {%- if config_paths.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'server' -%} - {%- if config_server.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'database' -%} - {%- if config_database.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'remote_cache' -%} - {%- if config_remote_cache.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'dataproxy' -%} - {%- if config_dataproxy.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'analytics' -%} - {%- if config_analytics.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'security' -%} - {%- if config_security.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'snapshots' -%} - {%- if config_snapshots.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'dashboards' -%} - {%- if config_dashboards.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'users' -%} - {%- if config_users.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.anonymous' -%} - {%- if config_auth_anonymous.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth' -%} - {%- if config_auth.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.google' -%} - {%- if config_auth_google.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.generic_oauth' -%} - {%- if config_auth_generic_oauth.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.grafana_com' -%} - {%- if config_auth_grafana_com.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.github' -%} - {%- if config_auth_github.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.proxy' -%} - {%- if config_auth_proxy.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.basic' -%} - {%- if config_auth_basic.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'auth.ldap' -%} - {%- if config_auth_ldap.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'smtp' -%} - {%- if config_smtp.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'emails' -%} - {%- if config_emails.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log' -%} - {%- if config_log.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.console' -%} - {%- if config_log_console.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.file' -%} - {%- if config_log_file.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'log.syslog' -%} - {%- if config_log_syslog.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'alerting' -%} - {%- if config_alerting.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'explore' -%} - {%- if config_explore.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'metrics' -%} - {%- if config_metrics.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'metrics.graphite' -%} - {%- if config_metrics_graphite.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'tracing.jaeger' -%} - {%- if config_tracing_jaeger.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'grafana_com' -%} - {%- if config_grafana_com.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'external_image_storage' -%} - {%- if config_external_image_storage.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'external_image_storage.s3' -%} - {%- if config_external_image_storage_s3.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'external_image_storage.webdav' -%} - {%- if config_external_image_storage_webdav.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'external_image_storage.gcs' -%} - {%- if config_external_image_storage_gcs.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'external_image_storage.azure_blob' -%} - {%- if config_external_image_storage_azure_blob.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'external_image_storage.local' -%} - {%- if config_external_image_storage_local.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'rendering' -%} - {%- if config_rendering.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'enterprise' -%} - {%- if config_enterprise.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'panels' -%} - {%- if config_panels.extend(config_parameters) -%}{%- endif -%} - {%- elif config_name == 'plugins' -%} - {%- if config_plugins.extend(config_parameters) -%}{%- endif -%} - {%- endif -%} - {%- endfor -%} -{%- endfor -%} - - -##################### Grafana Configuration Example ##################### -# -# Everything has defaults so you only need to uncomment things you want to -# change - -# possible values : production, development -{{ macros.config_row(config, 'app_mode', ';app_mode = production', 0, true) }} - -# instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty -{{ macros.config_row(config, 'instance_name', ';instance_name = ${HOSTNAME}', 0, true) }} - -#################################### Paths #################################### -[paths] -# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used) -{{ macros.config_row(config_paths, 'data', ';data = /var/lib/grafana', 0, true) }} - -# Temporary files in `data` directory older than given duration will be removed -{{ macros.config_row(config_paths, 'temp_data_lifetime', ';temp_data_lifetime = 24h', 0, true) }} - -# Directory where grafana can store logs -{{ macros.config_row(config_paths, 'logs', ';logs = /var/log/grafana', 0, true) }} - -# Directory where grafana will automatically scan and look for plugins -{{ macros.config_row(config_paths, 'plugins', ';plugins = /var/lib/grafana/plugins', 0, true) }} - -# folder that contains provisioning config files that grafana will apply on startup and while running. -{{ macros.config_row(config_paths, 'provisioning', ';provisioning = conf/provisioning', 0, true) }} - -#################################### Server #################################### -[server] -# Protocol (http, https, socket) -{{ macros.config_row(config_server, 'protocol', ';protocol = http', 0, true) }} - -# The ip address to bind to, empty will bind to all interfaces -{{ macros.config_row(config_server, 'http_addr', ';http_addr =', 0, true) }} - -# The http port to use -{{ macros.config_row(config_server, 'http_port', ';http_port = 3000', 0, true) }} - -# The public facing domain name used to access grafana from a browser -{{ macros.config_row(config_server, 'domain', ';domain = localhost', 0, true) }} - -# Redirect to correct domain if host header does not match domain -# Prevents DNS rebinding attacks -{{ macros.config_row(config_server, 'enforce_domain', ';enforce_domain = false', 0, true) }} - -# The full public facing url you use in browser, used for redirects and emails -# If you use reverse proxy and sub path specify full url (with sub path) -{{ macros.config_row(config_server, 'root_url', ';root_url = http://localhost:3000', 0, true) }} - -# Log web requests -{{ macros.config_row(config_server, 'router_logging', ';router_logging = false', 0, true) }} - -# the path relative working path -{{ macros.config_row(config_server, 'static_root_path', ';static_root_path = public', 0, true) }} - -# enable gzip -{{ macros.config_row(config_server, 'enable_gzip', ';enable_gzip = false', 0, true) }} - -# https certs & key file -{{ macros.config_row(config_server, 'cert_file', ';cert_file =', 0, true) }} -{{ macros.config_row(config_server, 'cert_key', ';cert_key =', 0, true) }} - -# Unix socket path -{{ macros.config_row(config_server, 'socket', ';socket =', 0, true) }} - -#################################### Database #################################### -[database] -# You can configure the database connection by specifying type, host, name, user and password -# as separate properties or as on string using the url properties. - -# Either "mysql", "postgres" or "sqlite3", it's your choice -{{ macros.config_row(config_database, 'type', ';type = sqlite3', 0, true) }} -{{ macros.config_row(config_database, 'host', ';host = 127.0.0.1:3306', 0, true) }} -{{ macros.config_row(config_database, 'name', ';name = grafana', 0, true) }} -{{ macros.config_row(config_database, 'user', ';user = root', 0, true) }} -# If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;""" -{{ macros.config_row(config_database, 'password', ';password =', 0, true) }} - -# Use either URL or the previous fields to configure the database -# Example: mysql://user:secret@host:port/database -{{ macros.config_row(config_database, 'url', ';url =', 0, true) }} - -# For "postgres" only, either "disable", "require" or "verify-full" -{{ macros.config_row(config_database, 'ssl_mode', ';ssl_mode = disable', 0, true) }} - -# For "sqlite3" only, path relative to data_path setting -{{ macros.config_row(config_database, 'path', ';path = grafana.db', 0, true) }} - -# Max idle conn setting default is 2 -{{ macros.config_row(config_database, 'max_idle_conn', ';max_idle_conn = 2', 0, true) }} - -# Max conn setting default is 0 (mean not set) -{{ macros.config_row(config_database, 'max_open_conn', ';max_open_conn =', 0, true) }} - -# Connection Max Lifetime default is 14400 (means 14400 seconds or 4 hours) -{{ macros.config_row(config_database, 'conn_max_lifetime', ';conn_max_lifetime = 14400', 0, true) }} - -# Set to true to log the sql calls and execution times. -{{ macros.config_row(config_database, 'log_queries', '') }} - -# For "sqlite3" only. cache mode setting used for connecting to the database. (private, shared) -{{ macros.config_row(config_database, 'cache_mode', ';cache_mode = private', 0, true) }} - -#################################### Cache server ############################# -[remote_cache] -# Either "redis", "memcached" or "database" default is "database" -{{ macros.config_row(config_remote_cache, 'type', ';type = database', 0, true) }} - -# cache connectionstring options -# database: will use Grafana primary database. -# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=grafana` -# memcache: 127.0.0.1:11211 -{{ macros.config_row(config_remote_cache, 'connstr', ';connstr =', 0, true) }} - -#################################### Data proxy ########################### -[dataproxy] - -# This enables data proxy logging, default is false -{{ macros.config_row(config_dataproxy, 'logging', ';logging = false', 0, true) }} - -# How long the data proxy should wait before timing out default is 30 (seconds) -{{ macros.config_row(config_dataproxy, 'timeout', ';timeout = 30', 0, true) }} - -# If enabled and user is not anonymous, data proxy will add X-Grafana-User header with username into the request, default is false. -{{ macros.config_row(config_dataproxy, 'send_user_header', ';send_user_header = false', 0, true) }} - -#################################### Analytics #################################### -[analytics] -# Server reporting, sends usage counters to stats.grafana.org every 24 hours. -# No ip addresses are being tracked, only simple counters to track -# running instances, dashboard and error counts. It is very helpful to us. -# Change this option to false to disable reporting. -{{ macros.config_row(config_analytics, 'reporting_enabled', ';reporting_enabled = true', 0, true) }} - -# Set to false to disable all checks to https://grafana.net -# for new vesions (grafana itself and plugins), check is used -# in some UI views to notify that grafana or plugin update exists -# This option does not cause any auto updates, nor send any information -# only a GET request to http://grafana.com to get latest versions -{{ macros.config_row(config_analytics, 'check_for_updates', ';check_for_updates = true', 0, true) }} - -# Google Analytics universal tracking code, only enabled if you specify an id here -{{ macros.config_row(config_analytics, 'google_analytics_ua_id', ';google_analytics_ua_id =', 0, true) }} - -# Google Tag Manager ID, only enabled if you specify an id here -{{ macros.config_row(config_analytics, 'google_tag_manager_id', ';google_tag_manager_id =', 0, true) }} - -#################################### Security #################################### -[security] -# default admin user, created on startup -{{ macros.config_row(config_security, 'admin_user', ';admin_user = admin', 0, true) }} - -# default admin password, can be changed before first start of grafana, or in profile settings -{{ macros.config_row(config_security, 'admin_password', ';admin_password = admin', 0, true) }} - -# used for signing -{{ macros.config_row(config_security, 'secret_key', ';secret_key = SW2YcwTIb9zpOOhoPsMm', 0, true) }} - -# disable gravatar profile images -{{ macros.config_row(config_security, 'disable_gravatar', ';disable_gravatar = false', 0, true) }} - -# data source proxy whitelist (ip_or_domain:port separated by spaces) -{{ macros.config_row(config_security, 'data_source_proxy_whitelist', ';data_source_proxy_whitelist =', 0, true) }} - -# disable protection against brute force login attempts -{{ macros.config_row(config_security, 'disable_brute_force_login_protection', ';disable_brute_force_login_protection = false', 0, true) }} - -# set to true if you host Grafana behind HTTPS. default is false. -{{ macros.config_row(config_security, 'cookie_secure', ';cookie_secure = false', 0, true) }} - -# set cookie SameSite attribute. defaults to `lax`. can be set to "lax", "strict" and "none" -{{ macros.config_row(config_security, 'cookie_samesite', ';cookie_samesite = lax', 0, true) }} - -# set to true if you want to allow browsers to render Grafana in a ,