Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it only use same table every query language? #12

Open
chestarss opened this issue Aug 27, 2015 · 0 comments
Open

is it only use same table every query language? #12

chestarss opened this issue Aug 27, 2015 · 0 comments

Comments

@chestarss
Copy link


:backends:

  • mysql
    :mysql:
    :host : localhost
    :user : root
    :pass : 123456
    :database : config

    :query:
    - select class_name as %{key} from %{ostype} as a,classes as b where a.class_id=b.class_id;
    - select value from node_params as a,nodes as b where a.node_id=b.node_id and b.fqdn='%{::fqdn}' and params='%{key}'

:logger: console

#i want use qurey one to select 'classes'

hiera -c /etc/hiera.yaml -a ostype=Debian classes

['nginx','ntp']

debian server auto include Debian table classes ,this is true.

but query two is not work.

hiera -c /etc/hiera.yaml ::fqdn=squid.example.com nginx::params::config_file_abs_path

it will execut query one language.

so how can make it work? juge filed name is exists in table ?

i want all is work
hiera -c hiera.yaml nginx::params::config_file_abs_path ::fqdn=squid.example.com
["/etc/nginx/nginx.conf"]

mysql> show tables;
+------------------+
| Tables_in_config |
+------------------+
| Debian |
| Redhat |
| classes |
| node_params |
| nodes |
| test |
+------------------+

mysql> select * from classes;
+----------+------------+
| class_id | class_name |
+----------+------------+
| 2 | nginx |
| 1 | ntp |
| 8 | puppet |
| 7 | test |
+----------+------------+
4 rows in set (0.00 sec)

mysql> select * from nodes
-> ;
+---------+--------------------+
| node_id | fqdn |
+---------+--------------------+
| 2 | debian.example.com |
| 1 | squid.example.com |
+---------+--------------------+
2 rows in set (0.00 sec)

mysql> select * from node_params;
+---------+-------------------------------------+-----------------------+
| node_id | param | value |
+---------+-------------------------------------+-----------------------+
| 1 | nginx::params::config_file_abs_path | /etc/nginx/nginx.conf |
+---------+-------------------------------------+-----------------------+
1 row in set (0.00 sec)

mysql> select * from Debian;
+----------+
| class_id |
+----------+
| 1 |
| 2 |
+----------+
2 rows in set (0.00 sec)

mysql> select * from Redhat;
+----------+
| class_id |
+----------+
| 7 |
+----------+
1 row in set (0.00 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants