Initial commit
This commit is contained in:
commit
5522463e89
29
Makefile
Normal file
29
Makefile
Normal file
@ -0,0 +1,29 @@
|
||||
eole-2.6.2:
|
||||
docker build \
|
||||
--build-arg HTTP_PROXY=$(HTTP_PROXY) \
|
||||
--build-arg HTTPS_PROXY=$(HTTPS_PROXY) \
|
||||
--build-arg http_proxy=$(http_proxy) \
|
||||
--build-arg https_proxy=$(https_proxy) \
|
||||
-t eolebase-2.6.2:latest \
|
||||
./misc/eole-2.6.2
|
||||
|
||||
ansible-eole: eole-2.6.2
|
||||
docker build \
|
||||
--build-arg HTTP_PROXY=$(HTTP_PROXY) \
|
||||
--build-arg HTTPS_PROXY=$(HTTPS_PROXY) \
|
||||
--build-arg http_proxy=$(http_proxy) \
|
||||
--build-arg https_proxy=$(https_proxy) \
|
||||
-t ansible-eole:latest \
|
||||
./misc/ansible-eole
|
||||
|
||||
dev-env:
|
||||
docker run \
|
||||
-it \
|
||||
--rm \
|
||||
-v "$(PWD)/src/eole_config.py:/ansible/lib/ansible/modules/system/eole_config.py:ro" \
|
||||
-v "$(PWD)/testdata:/testdata:ro" \
|
||||
--network host \
|
||||
--name ansible-creole-dev-env \
|
||||
ansible-eole
|
||||
|
||||
.PHONY: eole-2.6.2 ansible-eole
|
9
README.md
Normal file
9
README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Ansible - EOLE
|
||||
|
||||
Module Ansible permettant de configurer une distribution EOLE
|
||||
|
||||
## Ressources
|
||||
|
||||
- [Développement de modules Ansible](https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html)
|
||||
|
||||
/usr/lib/python2.7/dist-packages/tiramisu/config.py
|
20
misc/ansible-eole/Dockerfile
Normal file
20
misc/ansible-eole/Dockerfile
Normal file
@ -0,0 +1,20 @@
|
||||
FROM eolebase-2.6.2:latest
|
||||
|
||||
ARG HTTP_PROXY=
|
||||
ARG HTTPS_PROXY=
|
||||
ARG http_proxy=
|
||||
ARG https_proxy=
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update -y &&\
|
||||
apt-get install -y build-essential libssl-dev libffi-dev python-dev python-pip git &&\
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN git clone https://github.com/ansible/ansible.git &&\
|
||||
cd ansible &&\
|
||||
pip install wheel &&\
|
||||
pip install -r requirements.txt
|
||||
|
||||
COPY bashrc /root/.bashrc
|
||||
|
||||
WORKDIR ansible
|
1
misc/ansible-eole/bashrc
Normal file
1
misc/ansible-eole/bashrc
Normal file
@ -0,0 +1 @@
|
||||
. hacking/env-setup
|
39
misc/eole-2.6.2/Dockerfile
Normal file
39
misc/eole-2.6.2/Dockerfile
Normal file
@ -0,0 +1,39 @@
|
||||
FROM ubuntu:16.04
|
||||
|
||||
ARG HTTP_PROXY=
|
||||
ARG HTTPS_PROXY=
|
||||
ARG http_proxy=
|
||||
ARG https_proxy=
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# systemd/docker compatibility configuration
|
||||
# See https://developers.redhat.com/blog/2016/09/13/running-systemd-in-a-non-privileged-container/
|
||||
ENV container=docker
|
||||
STOPSIGNAL SIGRTMIN+3
|
||||
|
||||
RUN apt-get update -y && apt-get install -y locales wget keyboard-configuration
|
||||
RUN locale-gen --purge fr_FR.UTF-8
|
||||
|
||||
ENV LC_ALL=fr_FR.UTF-8
|
||||
ENV LANG=french
|
||||
|
||||
# Install apt-show-versions
|
||||
# See https://askubuntu.com/questions/916199/install-apt-show-versions-inside-an-ubuntu-docker-container
|
||||
RUN rm /etc/apt/apt.conf.d/docker-gzip-indexes &&\
|
||||
apt-get purge apt-show-versions &&\
|
||||
rm /var/lib/apt/lists/*lz4 &&\
|
||||
apt-get -o Acquire::GzipIndexes=false update &&\
|
||||
apt-get install -y apt-show-versions
|
||||
|
||||
# Configure then install EOLE packages
|
||||
RUN wget -q -O - "http://eole.ac-dijon.fr/eole/project/eole-2.6-repository.key" | apt-key --keyring /etc/apt/trusted.gpg.d/eole-archive-keyring.gpg add -
|
||||
COPY eole.list /etc/apt/sources.list.d/eole.list
|
||||
RUN apt-get update -y &&\
|
||||
apt-get install -y --force-yes eole-server eole-exim-pkg &&\
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV DEBIAN_FRONTEND=text
|
||||
|
||||
ENTRYPOINT []
|
||||
|
||||
CMD ["/bin/bash"]
|
3
misc/eole-2.6.2/eole.list
Normal file
3
misc/eole-2.6.2/eole.list
Normal file
@ -0,0 +1,3 @@
|
||||
deb http://eole.ac-dijon.fr/eole eole-2.6.2 main cloud
|
||||
deb http://eole.ac-dijon.fr/eole eole-2.6.2-security main cloud
|
||||
deb http://eole.ac-dijon.fr/eole eole-2.6.2-updates main cloud
|
133
src/eole_config.py
Normal file
133
src/eole_config.py
Normal file
@ -0,0 +1,133 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
ANSIBLE_METADATA = {
|
||||
'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'
|
||||
}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: creole
|
||||
|
||||
short_description: This is my sample module
|
||||
|
||||
version_added: "2.4"
|
||||
|
||||
description:
|
||||
- "This is my longer description explaining my sample module"
|
||||
|
||||
options:
|
||||
name:
|
||||
description:
|
||||
- This is the message to send to the sample module
|
||||
required: true
|
||||
new:
|
||||
description:
|
||||
- Control to demo if the result of this module is changed or not
|
||||
required: false
|
||||
|
||||
extends_documentation_fragment:
|
||||
- azure
|
||||
|
||||
author:
|
||||
- Your Name (@yourhandle)
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Pass in a message
|
||||
- name: Test with a message
|
||||
my_new_test_module:
|
||||
name: hello world
|
||||
|
||||
# pass in a message and have changed true
|
||||
- name: Test with a message and changed output
|
||||
my_new_test_module:
|
||||
name: hello world
|
||||
new: true
|
||||
|
||||
# fail the module
|
||||
- name: Test failure of the module
|
||||
my_new_test_module:
|
||||
name: fail me
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
original_message:
|
||||
description: The original name param that was passed in
|
||||
type: str
|
||||
message:
|
||||
description: The output message that the sample module generates
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from creole.loader import creole_loader, config_save_values
|
||||
|
||||
def run_module():
|
||||
|
||||
# define available arguments/parameters a user can pass to the module
|
||||
module_args = dict(
|
||||
name=dict(type='str', required=True),
|
||||
value=dict(type='json', required=False),
|
||||
load_extra=dict(type='bool', required=False, default=True),
|
||||
check_mandatory=dict(type='bool', required=False, default=False),
|
||||
reload_config=dict(type='bool', required=False, default=False),
|
||||
)
|
||||
|
||||
result = dict(
|
||||
changed=False,
|
||||
original_message='',
|
||||
message=''
|
||||
)
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=module_args,
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
||||
update_value = not module.params['value'] is None
|
||||
c = creole_loader(rw=update_value, load_extra=module.params['load_extra'])
|
||||
|
||||
path = c.creole.find_first(byname=module.params['name'], type_='path')
|
||||
value = getattr(c, path)
|
||||
|
||||
result['state'] = dict(
|
||||
name=module.params['name'],
|
||||
value=value
|
||||
)
|
||||
|
||||
if update_value:
|
||||
setattr(c, path, module.params['value'])
|
||||
if not module.check_mode:
|
||||
try:
|
||||
config_save_values(
|
||||
c, 'creole',
|
||||
check_mandatory=module.params['check_mandatory'],
|
||||
reload_config=module.params['reload_config']
|
||||
)
|
||||
result['changed'] = True
|
||||
except e:
|
||||
module.fail_json(msg=str(e), **result)
|
||||
else:
|
||||
value = getattr(c, path)
|
||||
|
||||
# use whatever logic you need to determine whether or not this module
|
||||
# made any modifications to your target
|
||||
# if module.params['new']:
|
||||
# result['changed'] = True
|
||||
|
||||
# during the execution of the module, if there is an exception or a
|
||||
# conditional state that effectively causes a failure, run
|
||||
# AnsibleModule.fail_json() to pass in the message and the result
|
||||
# if module.params['name'] == 'fail me':
|
||||
# module.fail_json(msg='You requested this to fail', **result)
|
||||
|
||||
# in the event of a successful module execution, you will want to
|
||||
# simple AnsibleModule.exit_json(), passing the key/value results
|
||||
module.exit_json(**result)
|
||||
|
||||
def main():
|
||||
run_module()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
5
testdata/args.json
vendored
Normal file
5
testdata/args.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"ANSIBLE_MODULE_ARGS": {
|
||||
"name": "activer_firewall"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user