Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
405 changes: 405 additions & 0 deletions doc-env/Scripts/Activate.ps1

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions doc-env/Scripts/activate
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly

deactivate () {
# reset old environment variables
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi

# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi

if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
PS1="${_OLD_VIRTUAL_PS1:-}"
export PS1
unset _OLD_VIRTUAL_PS1
fi

unset VIRTUAL_ENV
unset VIRTUAL_ENV_PROMPT
if [ ! "${1:-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}

# unset irrelevant variables
deactivate nondestructive

VIRTUAL_ENV="C:\git\Documentation\doc-env"
export VIRTUAL_ENV

_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/Scripts:$PATH"
export PATH

# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "${PYTHONHOME:-}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
unset PYTHONHOME
fi

if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
PS1="(doc-env) ${PS1:-}"
export PS1
VIRTUAL_ENV_PROMPT="(doc-env) "
export VIRTUAL_ENV_PROMPT
fi

# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi
34 changes: 34 additions & 0 deletions doc-env/Scripts/activate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@echo off

rem This file is UTF-8 encoded, so we need to update the current code page while executing it
for /f "tokens=2 delims=:." %%a in ('"%SystemRoot%\System32\chcp.com"') do (
set _OLD_CODEPAGE=%%a
)
if defined _OLD_CODEPAGE (
"%SystemRoot%\System32\chcp.com" 65001 > nul
)

set VIRTUAL_ENV=C:\git\Documentation\doc-env

if not defined PROMPT set PROMPT=$P$G

if defined _OLD_VIRTUAL_PROMPT set PROMPT=%_OLD_VIRTUAL_PROMPT%
if defined _OLD_VIRTUAL_PYTHONHOME set PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%

set _OLD_VIRTUAL_PROMPT=%PROMPT%
set PROMPT=(doc-env) %PROMPT%

if defined PYTHONHOME set _OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%
set PYTHONHOME=

if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH%
if not defined _OLD_VIRTUAL_PATH set _OLD_VIRTUAL_PATH=%PATH%

set PATH=%VIRTUAL_ENV%\Scripts;%PATH%
set VIRTUAL_ENV_PROMPT=(doc-env)

:END
if defined _OLD_CODEPAGE (
"%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul
set _OLD_CODEPAGE=
)
22 changes: 22 additions & 0 deletions doc-env/Scripts/deactivate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@echo off

if defined _OLD_VIRTUAL_PROMPT (
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
)
set _OLD_VIRTUAL_PROMPT=

if defined _OLD_VIRTUAL_PYTHONHOME (
set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
set _OLD_VIRTUAL_PYTHONHOME=
)

if defined _OLD_VIRTUAL_PATH (
set "PATH=%_OLD_VIRTUAL_PATH%"
)

set _OLD_VIRTUAL_PATH=

set VIRTUAL_ENV=
set VIRTUAL_ENV_PROMPT=

:END
Binary file added doc-env/Scripts/pip.exe
Binary file not shown.
Binary file added doc-env/Scripts/pip3.10.exe
Binary file not shown.
Binary file added doc-env/Scripts/pip3.exe
Binary file not shown.
Binary file added doc-env/Scripts/python.exe
Binary file not shown.
Binary file added doc-env/Scripts/pythonw.exe
Binary file not shown.
3 changes: 3 additions & 0 deletions doc-env/pyvenv.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
home = C:\Users\ASUS\AppData\Local\Programs\Python\Python310
include-system-site-packages = false
version = 3.10.0
59 changes: 59 additions & 0 deletions docs/Ansible/setupAnsible.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Set Up Ansible
=================

1- install ansible in controller server :

.. code-block:: bash

sudo apt install ansible

then set the secure shell between controller and node .make an ssh key with passphrase send the public key to the node

.. code-block:: bash

ansible-copy-id key.pub <node-ipaddress>

test the ssh to the node .

then make another ssh key only for ansible with out an passphrase and send the public key to the node .

.. note::

the first ssh key is the defualt key to ssh to the node.you could speciefy which key to make ssh by:

.. code-block:: bash

ssh -i ~/.ssh/ansible <node-ipadress>

.. note::

check the content of authorizedkey file in node side to make sure the contents of ansible.pub and defualtkey.pub is there.

now lets set the inventory file which contains the host ip addresses.

in the inventory file or hosts file which is defualt inventory file in /etc/ansible/hosts .

put the nodes's ip addresses in hosts file .

.. note::

you could put all ip addresses in one group with a tag like :

[dbservers]
ipaddress-server1
ipaddress-server2
ipaddress-server3

in ansible.cfh file set the inventory file as inventory = hosts and speciefy the Private key :

private_key_file = ~/.ssh/ansible

so ansible use this key by defualt to ssh to the node servers.

now lets test the reachability of nodes with this command :

.. code-block:: bash

ansible all -m ping

the result should be `pong`.
67 changes: 67 additions & 0 deletions docs/Ansible/writePlaybook.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

Write playbook
==================


playbook contains instructions that should be played in the node servers such as install or
updating packages automatically with out accessing derictively to the node servers.


playbook is written in yaml form which is so simple to read and understand to human.
it start with --- and contains the name of the group or hosts on which it should played.


.. code-block:: yaml

---
- hosts: dbservers
sudo: yes
tasks:
- name: install apache2
apt: name=apache2 update_cache=yes state=latest

this playbook install and update apache2 .


so lets check the syntax of the playbook .

.. code-block:: bash

ansible-playbook nameofthefile.yml --syntax-check

then if the result was ok playthe file with :

.. code-block:: bash

ansible-playbook nameofthefile.yml


the result should be something like this if it was successfull:

.. code-block:: console

PLAY [apache] ******************************************************************

TASK [Gathering Facts] *********************************************************
ok: [secondary_server_ip]

TASK [install apache2] *********************************************************

changed: [secondary_server_ip]

PLAY RECAP *********************************************************************
secondary_server_ip : ok=2 changed=1 unreachable=0 failed=0


you could check the apache server is running by enter the ip address of node in your browser.


.. tip::

**Reference Links**

* `amazing tutorial on youtube <https://youtu.be/3RiVKs8GHYQ>`_
* `ansible doc <https://docs.ansible.com/>`_



8 changes: 8 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ This Text contains **Bold \* Example \`**

FakeNews/TelegramBot

.. toctree::
:maxdepth: 3
:caption: Ansible
:hidden:

Ansible/setupAnsible
Ansible/writePlaybook


Indices and tables
==================
Expand Down
1 change: 1 addition & 0 deletions private-docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Welcome to Private Documentations's documentation!

PVQA/pvqa-generateQA/GenerateQA.rst


Indices and tables
==================

Expand Down